ImageMagick - probem with image width and height

Hallo all,

i have a problem using imagemagick to display an image on a view. This, because identify every time gives the higher number of image size first, so i does not can display the picture right, because all are landscape.

Do you have the same problem? Is it a error in ImageMagick of Haiku?

identify /path/to/input.image

example:

identify /boot/home/.besly/IMtest/test.jpeg

output:

/boot/home/.besly/IMtest/test.jpeg JPEG 3648x2736 3648x2736+0+0 8-bit sRGB 6.002MB 0.014u 0:00.013

but the picture have a 2736x3648 (x,y)

First, it seems test.png is a JPEG file? confusing :stuck_out_tongue:

In JPEG files, there is sometimes a physical resolution which tells how the pixels are stored in the file, but then EXIF data says “rotate this picture 90°”. This is made automatically by some smartphones and cameras (they always take the picture in the same direction, but there is an accelerometer to tell "this should be rotated when displaying). And, you can also edit this with some tools, including windows picture viewer (it allows lossless rotation of JPEG images, without this feature you would need to re-encode the whole file just to rotate it).

I just want to display the image as preview and I have to represent it correctly but x, y and not y, x.

Looks like a bug to me. My Linux identify correctly shows dimensions for portrait and landscape images.
Its not hard to imagine a workaround for this bug, but I think its better to use something without bugs. I know Haiku can load and display images natively. Load image, get image size, resize and display based on native API’s?

Cheers

1 Like

Try running this first

mogrify -auto-orient original_file.jpg

As the other folks have pointed out, this is a matter of how the image data is stored. My camera, for instance (like all others I suspect) always stores the image in landscape mode, but adds an ‘Orientation’ descriptor that says how it should be rotated for viewing. Viewing apps (like ShowImage) usually take account of this properly. ArtPaint will read the file and orient it correctly too (via the translator, I assume) but if you write out the image again it gets the visible width and height, with no orientation value.

That’s definitely another annoyance of ImageMagick, that it doesn’t observe or have an easy way to get the orientation. One way to get it would be to do:
'identify -verbose /boot/home/.besly/IMtest/test.jpeg',
and the Orientation will be included in the – long – output. You could grep that to isolate it, but it’s all very slow.

Or you could use the mogrify command that Michel found to adjust the original.

Thanks for the tip. looks like it take effect :slight_smile: