jamji
jamji

Reputation: 27

Does anyone know how to convert to little endian .pfm file from ImageMagic?

I'm looking for method about to convert little endian.pfm file from imageMagick.

As I know we can get a pfm file like this.

convert input.bmp output.pfm

This output file is made by Big endian. But I want to convert as Little endian.

So is there any method to convert to Little endian from Big endian on ImageMagick?

Thanks

Upvotes: 1

Views: 2104

Answers (1)

emcconville
emcconville

Reputation: 24419

Endian can be controlled with -endian option.

Example. Create a 2x2 red PFM image with little endian, and write to hexdump.

$ convert -size 2x2 xc:red -endian LSB PFM:- | hexdump

0000000 50 46 0a 32 20 32 0a 2d 31 2e 30 0a 00 00 80 3f
0000010 00 00 00 00 00 00 00 00 00 00 80 3f 00 00 00 00
0000020 00 00 00 00 00 00 80 3f 00 00 00 00 00 00 00 00
0000030 00 00 80 3f 00 00 00 00 00 00 00 00            
000003c

You can confirm the little endian by translating the header.

50 46 0a 32 20 32 0a 2d 31 2e 30 0a 00 00 80 3f
                     |         |    |         |
little endian -------| "-1.0"  |    | LSM data|

Repeat above with big endian.

$ convert -size 2x2 xc:red -endian MSB PFM:- | hexdump

0000000 50 46 0a 32 20 32 0a 31 2e 30 0a 3f 80 00 00 00
0000010 00 00 00 00 00 00 00 3f 80 00 00 00 00 00 00 00
0000020 00 00 00 3f 80 00 00 00 00 00 00 00 00 00 00 3f
0000030 80 00 00 00 00 00 00 00 00 00 00               
000003b

and observe...

50 46 0a 32 20 32 0a 31 2e 30 0a 3f 80 00 00 00
                     |      |    |         |
big endian ----------| "1.0"|    | MSB data|

Upvotes: 6

Related Questions