Page 1 of 1

how to detect PC or MAC byte order?

Posted: 2010-06-25T09:41:15-07:00
by markzman
can imagemagick detect whether a tiff file has a PC or Mac byte order?

Re: how to detect PC or MAC byte order?

Posted: 2010-06-25T11:00:56-07:00
by fmw42
use identify -verbose image

and look at the ENDIANESS: value

identify -verbose logo2.tif

logo2.tif
Image: logo2.tif
Format: TIFF (Tagged Image File Format)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: PixelsPerCentimeter
Type: Palette
Base type: Palette
Endianess: MSB
...

Re: how to detect PC or MAC byte order?

Posted: 2010-06-25T14:54:02-07:00
by markzman
Thanks for the reply.
I think there's a bug with the new release, the Endianess value are the same see below report from PC and MAC sample tif.
Running ImageMagick-6.6.2-7-Q16-windows-dll.exe

1. PC byte order
Image: sample_PC.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 1907x1053+0+0
Resolution: 300x300
Print size: 6.35667x3.51
Units: PixelsPerInch
Type: TrueColorMatte
Base type: TrueColor
Endianess: MSB
Colorspace: RGB
Depth: 8-bit

2. MAC byte order
Image: sample_MAC.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 1907x1053+0+0
Resolution: 300x300
Print size: 6.35667x3.51
Units: PixelsPerInch
Type: TrueColorMatte
Base type: TrueColor
Endianess: MSB
Colorspace: RGB
Depth: 8-bit

Re: how to detect PC or MAC byte order?

Posted: 2010-06-25T15:47:38-07:00
by fmw42
How do you know your two files were not written with the same byte order? Often software on various systems allow one to choose or has a default as one or other if you don't specify. How did you create the two images?

Endian reporting seems fine.


convert logo2.tif -endian LSB logo2_lsb.tif
identify -verbose logo2_lsb.tif


Format: TIFF (Tagged Image File Format)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: PixelsPerCentimeter
Type: Palette
Base type: Palette
Endianess: LSB

This is from IM 6.6.2-7 Q16 Mac OSX Tiger

By the way, Mac uses both: Intel-based is little endian and PowerPC-based is big endian.

Also see http://en.wikipedia.org/wiki/Tagged_Image_File_Format where it says:


"Every TIFF begins with a 2-byte indicator of byte order: "II" for little endian and "MM" for big endian byte ordering. ... The TIFF 6.0 specification says that compliant TIFF readers must support both byte orders (II and MM), however, TIFF writers may choose the byte order convenient for their image.[8] This gave rise to the image-processing community's joke that TIFF is an acronym for Thousands of Incompatible File Formats.[9]"

Re: how to detect PC or MAC byte order?

Posted: 2010-06-28T07:57:31-07:00
by markzman
I'm using Photoshop CS3 on Windows XP.
The sample tiffs do have the "MM" indicator for MAC and "II" for the PC byte order but when I use the -verbose command i only get MSB for both.

Re: how to detect PC or MAC byte order?

Posted: 2010-06-28T11:03:50-07:00
by fmw42
perhaps photoshop has a bug and only writes it one way. have you tried verifying the endian with some other third party tool to verify which is in error photoshop or IM?

Why don't you post a link to two small example of writing out from PS both ways. So others can check it out also directly from your images.

Re: how to detect PC or MAC byte order?

Posted: 2010-06-28T12:56:58-07:00
by markzman
i tried re-saving them on other pc still the same output, see below sample tiff files.

sample PC byte order
http://www.clipartof.com/images/free_ho ... le_pc.tiff

sample MAC byte order
http://www.clipartof.com/images/free_ho ... e_mac.tiff

Re: how to detect PC or MAC byte order?

Posted: 2010-06-28T13:05:29-07:00
by fmw42
I opened both your files in Mac GraphicConverter and it said one was big endian (mac) and the other little endian (pc).

IM tells me both are MSB.

So perhaps there may be a bug in IM or your files are not written according to spec. There were some oddities, such as multiple alpha channels and multiple IPTC sets of data.

I am certainly no expert on tiff format. So you will need one of the IM experts on format to investigate further.

Perhaps you should open a post on the bugs forum and put a link back to this topic.

Re: how to detect PC or MAC byte order?

Posted: 2010-06-28T13:39:09-07:00
by markzman
The files were re-saved a couple of times while troubleshooting if Photoshop or IM was the problem.
I'll post this on bugs section and see what comes out.

Re: how to detect PC or MAC byte order?

Posted: 2010-07-01T12:46:49-07:00
by markzman
Now works on IM 6.6.2-10 Q16
See related post - viewtopic.php?f=3&t=16524