metacopy -e a.tif b.tif
Added by Anonymous over 5 years ago
It does not copy DPI information. a.tiff is 300 DPI. b.tiff is kept with 96 DPI.
I have tried with "-a" option, and does not work.
But, it worked with JPG files.
I can send the source TIF image (a.tif) in private, since it contains some "private information".
Thanks for any help
Ritz
Replies (12)
RE: metacopy -e a.tif b.tif - Added by Robin Mills over 5 years ago
Ritz
I think that tag is protected from change. There are tags that exiv2 considers to be part of the image and will not change them. For example XDimension etc. If those are changed, the image will be corrupted. You'll find them listed in src/tiffimage.cpp#2441
bool isTiffImageTag(uint16_t tag, IfdId group) { //! List of TIFF image tags static const TiffImgTagStruct tiffImageTags[] = { { 0x00fe, ifd0Id }, // Exif.Image.NewSubfileType ... { 0x011a, ifd0Id }, // Exif.Image.XResolution { 0x011b, ifd0Id }, // Exif.Image.YResolution ... { 0x9217, ifd0Id }, // Exif.Image.SensingMethod };You can try commenting off Exif.Image.{X|Y}Resolution. I'm a little surprised that {X|Y}Resolution are treated this way, perhaps the author was being cautious to cover the case when {X|Y}Dimension is expressed in units which are not pixels.
If that doesn't fix, please share your tiff with Dropbox or something. Or you can email it, or simply attach it to this issue and I will delete your file from this issues when I copy it to my machine.
RE: metacopy -e a.tif b.tif - Added by Anonymous over 5 years ago
Hello... here the sample images (trying metacopy -a x.tif y.tif)... also, tried any other parameter, like -e or -c or -i...
I know that dimensions are different. But there should be a way to copy the DPI only.
I tried to use metacopy, but it does not copy the DPI information...
Thanks in advance for any help ...
Best Regards!
Ritz
RE: metacopy -e a.tif b.tif - Added by Robin Mills over 5 years ago
Ritz
You'll have to read the code in metacopy to see if it copies DPI information. I did run a little test last week before offering the advice above about src/tiffimage.cpp#2441 isTiffImageTag() resulting in Exif.Image.XResolution being considered part of the image data and therefore protected.
RE: metacopy -e a.tif b.tif - Added by T Modes over 5 years ago
Just one comment: you can not update XResolution or YResolution alone. You need also to consider/update ResolutionUnit.
And when you change ResolutionUnit you need also to update XPosition and YPosition otherwise you break cropped TIFF files.
RE: metacopy -e a.tif b.tif - Added by Anonymous over 5 years ago
Hi Guys...I have tried many things... still, DPI is 96 (and it should be 300). Why is it too hard to change a "logic" unit in the file?. I have not found any solution on internet. My last try was this code:
Exiv2::BasicIo::AutoPtr io(new Exiv2::FileIo(output));
Exiv2::TiffImage tiffImage(io, false);
Exiv2::ExifData& exifData = tiffImage.exifData();
exifData["Exif.Image.ResolutionUnit"] = 2;
exifData["Exif.Image.XResolution"] = Exiv2::Rational(300, 1);
exifData["Exif.Image.YResolution"] = Exiv2::Rational(300, 1);
exifData["Exif.Image.Make"] = "Just for testing";
tiffImage.writeMetadata();
And of course, it only writes on this tag "Exif.Image.Make" properly. I have tried with other configurations
exifData["Exif.Image.XResolution"] = Exiv2::Rational(1, 300);
exifData["Exif.Image.YResolution"] = Exiv2::Rational(1, 300);
Or just numbers
exifData["Exif.Image.XResolution"] = 300;
exifData["Exif.Image.YResolution"] = 300;
Nothing Works... also
exifData["Exif.Image.ResolutionUnit"] = 1;
I dont know any other c++ library for chaging the DPI information on a TIFF image. So, what should I do? just give up?
Cheers
Ritz
RE: metacopy -e a.tif b.tif - Added by Robin Mills over 5 years ago
I have explained this several times. You will have to modify isTiffImageTag() to stop that tag from being protected, then you will be able to modify it with a command such as
$ exiv2 -M'set Exif.Image.XResolution 200/1 image-pathI can't say off-hand whether metacopy.cpp will deal with Resolution. This an open source project. You get free source code and you are expected to modify the code if it doesn't do exactly what you want. If metacopy doesn't work to your liking, you are expected to read the code and modify it.
I also suggest that using words such as "please" and "thank you" might motivate me to give you more of my time.
RE: metacopy -e a.tif b.tif - Added by Anonymous over 5 years ago
Hello Robin
Thanks for your help. I dont understand the code at all. That's why I have not tried your approach. You are talking about commentting off some lines here:
static const TiffImgTagStruct tiffImageTags[] = {
{ 0x00fe, ifd0Id }, // Exif.Image.NewSubfileType
{ 0x00ff, ifd0Id }, // Exif.Image.SubfileType
{ 0x0100, ifd0Id }, // Exif.Image.ImageWidth
{ 0x0101, ifd0Id }, // Exif.Image.ImageLength
{ 0x0102, ifd0Id }, // Exif.Image.BitsPerSample
{ 0x0103, ifd0Id }, // Exif.Image.Compression
{ 0x0106, ifd0Id }, // Exif.Image.PhotometricInterpretation
{ 0x010a, ifd0Id }, // Exif.Image.FillOrder
{ 0x0111, ifd0Id }, // Exif.Image.StripOffsets
{ 0x0115, ifd0Id }, // Exif.Image.SamplesPerPixel
{ 0x0116, ifd0Id }, // Exif.Image.RowsPerStrip
{ 0x0117, ifd0Id }, // Exif.Image.StripByteCounts
{ 0x011a, ifd0Id }, // Exif.Image.XResolution
{ 0x011b, ifd0Id }, // Exif.Image.YResolution
Do you mean, comment these 2 lines? like this?:
//{ 0x011a, ifd0Id }, // Exif.Image.XResolution
//{ 0x011b, ifd0Id }, // Exif.Image.YResolution
Thx again
Ritz
RE: metacopy -e a.tif b.tif - Added by Robin Mills over 5 years ago
You have the correct idea. You have to comment off those two lines of code and rebuild exiv2. Then you will be able to modify XResolution.
On which platform are you working? Linux, Mac, Windows?
I'm having an early night (it's 22:20 in England). Speak Saturday.
RE: metacopy -e a.tif b.tif - Added by Anonymous over 5 years ago
Hello robin
I am using windows10 ... by the way, I have commented 3 lines (also considering the hints of "T Modes").
//{ 0x011a, ifd0Id }, // Exif.Image.XResolution
//{ 0x011b, ifd0Id }, // Exif.Image.YResolution
{ 0x011c, ifd0Id }, // Exif.Image.PlanarConfiguration
{ 0x0122, ifd0Id }, // Exif.Image.GrayResponseUnit
{ 0x0123, ifd0Id }, // Exif.Image.GrayResponseCurve
{ 0x0124, ifd0Id }, // Exif.Image.T4Options
{ 0x0125, ifd0Id }, // Exif.Image.T6Options
//{ 0x0128, ifd0Id }, // Exif.Image.ResolutionUnit
Now, the resolution unit is written. That's good. But still Xres and Yres are 96. "T Modes" told me that I should update XPosition and YPosition. But I dont see these tags.
Cheers
Ritz
RE: metacopy -e a.tif b.tif - Added by Anonymous over 5 years ago
Hello
Well, I just read the metadata from other file, and write it into my tif file (as metacopy does) and now it Works (after commenting the 3 lines). I did not find the way to change the DPI only. But it Works for me by now.
Thanks Robin and T Modes.
Best Regards!
Ritz
RE: metacopy -e a.tif b.tif - Added by Robin Mills over 5 years ago
Well done, Ritz and T. I wake up to a beautiful sunny morning in England and delighted to read your happy news. The code and the community are working perfectly. Thanks for sharing your progress and success.
dsc_9221.jpg (85.5 KB) dsc_9221.jpg |
RE: metacopy -e a.tif b.tif - Added by Anonymous over 5 years ago
Wow....nice pic! Have a nice day!
Ritz