[PS Error]TIFF changes from MSB to LSB after adding metadata

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
jdsousa
Posts: 6
Joined: 2014-04-29T09:55:53-07:00
Authentication code: 6789

[PS Error]TIFF changes from MSB to LSB after adding metadata

Post by jdsousa »

Hello, this is my first post on this forum because i'm having a problem that is driving me nuts. (like most of the people that places a post here)

This problem may be related with the tiff library and not the c++ part, but since i'm using Magick++ i decided to post here.

I have an image that was created with Photoshop and saved has MSB. I inject some custom meta-data on the image (on comments and artist) and when i download it througth my app it is LSB instead of keeping the MSB.

I have tried to force it invoking

Code: Select all

image->endian(MagickCore::MSBEndian)
but it only changes the FillOrder, the ExifByteOrder remains LSB instead of MSB.

The curious thing is that the 6.8.3 version was working, after adding on «ReadTIFFImage» function from tiff.c an invokation to:

Code: Select all

(void) SetImageArtifact(image,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ? "lsb" : "msb");
Now i upgraded to the most recent version (6.8.9) because the old one had a memory leak problem, which was fixed, the code on that file evolved and when comparing the old version with the new one, the previous call does not make sense any more.

I cannot figure out how to solve this problem, can someone help me please? Feel free to ask for more details. I did not provided an image because any saved has MSB will do the "trick".

Sorry for not providing code, i will try to create a sample of the workflow i'm using if it's needed.

Thank you.

P.S.: The error is only displayed in photoshop, other image editing programs can open it.
P.S.2: Found the endian "problem" using Exiftool.
Last edited by jdsousa on 2014-04-29T10:53:00-07:00, edited 1 time in total.
jdsousa
Posts: 6
Joined: 2014-04-29T09:55:53-07:00
Authentication code: 6789

Re: [PS Error]TIFF changes from MSB to LSB after adding meta

Post by jdsousa »

Found an old post of similar problem:

viewtopic.php?f=3&t=20530
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: [PS Error]TIFF changes from MSB to LSB after adding meta

Post by dlemstra »

Have you tried changing SetImageArtifact to SetImageOption?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jdsousa
Posts: 6
Joined: 2014-04-29T09:55:53-07:00
Authentication code: 6789

Re: [PS Error]TIFF changes from MSB to LSB after adding meta

Post by jdsousa »

Hello,

thank you for anwsering.

On ReadTIFFImage i've tried:

Code: Select all

	(void) SetImageArtifact(image,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ? "lsb" : "msb");
	(void) SetImageProperty(image,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ? "lsb" : "msb");
	(void) SetImageOption(AcquireImageInfo(),"tiff:endian",TIFFIsBigEndian(tiff) == 0 ? "lsb" : "msb");
	(void) SetImageOption((ImageInfo*)image_info,"tiff:endian",TIFFIsBigEndian(tiff) == 0 ? "lsb" : "msb");
and none worked. The output image keeps having LSB instead of MSB, has the original. I'm guessing that's why photoshop refuses to open the image.


Any more ideas?
jdsousa
Posts: 6
Joined: 2014-04-29T09:55:53-07:00
Authentication code: 6789

Re: [PS Error]TIFF changes from MSB to LSB after adding meta

Post by jdsousa »

Ok, after your comment and a good coffee, i decided to try something else and it worked.

I looked where the "tiff:endian" value was readed and what was the function used.

So i found that on the WriteTIFFImage (~Ln #2808, tiff.c) it was used

Code: Select all

 GetImageOption(...)
changed it to

Code: Select all

 GetImageProperty(...)
and it worked!

The read function used the image property to set the image's endian value but the write was getting the value using another function.
(I don't know anything about the internals of those functions)

Can you talk to who maintains that part of the IM about this fix?

Thanks!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: [PS Error]TIFF changes from MSB to LSB after adding meta

Post by dlemstra »

I just realized you are using Magick++..... You don't need to call SetImageOption. The following should work:

Code: Select all

image->defineValue("tiff", "endian",TIFFIsBigEndian(tiff) == 0 ? "lsb" : "msb");
image->write("output.tiff");
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jdsousa
Posts: 6
Joined: 2014-04-29T09:55:53-07:00
Authentication code: 6789

Re: [PS Error]TIFF changes from MSB to LSB after adding meta

Post by jdsousa »

That did not work, i am sticking to the solution i have found.

Thank you for your time!
Post Reply