Cfimage/info swaps width and height of photos (sometimes)

Hi all,
I have a problem determining the height and width of photos in jpg-format in pixels with ‘cfimage/info’. The height and width of photos in portrait format are often swapped, what causes problems when these photos are cropped in a later process. Some photos in portrait format are recognized correctly. Others won’t. I don’t see any regularity either.

These are the functions I use to determine height and width :
<cfimage action="info" source="/mediadb/IMG_5766.jpg" structName="result">

or

<cfscript>
  imgObj = imageRead("/mediadb/IMG_5766.jpg");
  info = imgObj.info();
  writeDump(info);
</cfscript>

Is there a reliable way to find out if a jpeg photo is portrait or landscape?

Don’t forget to tell us about your stack!

OS: Ubuntu 20.04
Java Version: 17.0.3
Tomcat Version: 9.0.31
Lucee Version: 5.3.8.206

got a sample image you can share which reproduces the problem?

which version of the image extension are you using?

I would update your version of Tomcat, its insecure as hell and has a ton of bugs.

After you have updated tomcat to the latest stable 9.0.62 try rerunning the code.

Additionally you may want to move from Ubuntu to Debian, as Ubuntu is built off Debian’s beta ring. For stability and ultra long stable security updates, Debian is known for this. Ubuntu, even their LTSC items break on update. In Debian you update the apt repos , clear your apt-cache and then do another apt update and apt upgrade respectively.

1 Like

Ok. I’m considering rewrite my ImageService and I was thinking of using Lucee’s built-in functions (now I’m using a CustomTag that wrap ImageMagik).

I got a little worried :slight_smile:

So I tried on about 25751 images, and I have about 54 mismatch (mismatch not Lucee error…).

All mismatch come from images that are misdirected, like this one:

18574_19783

Data of this image:
ImageMagickWidth:400 - LuceeWidth:600
ImageMagickHeight:600 - LuceeHeight:400
ImageMagickOrientation:RightTop - LuceeOrientation:6 ( → RightTop)

Looking at the picture, it seems Lucee is right.

The orientation value always seems correct (even if it is often not available).

If you need them, I can provide any images that have had a mismatch, for your debugging.

Hope this helps

I would look at the raw images and see if they are being uploaded with windows meta data.
There is a windows attribute for images that includes orientation. On windows this works in some programs, but on linux and anything else that doesn’t understand the meta data, it doesn’t work as the image is correctly scanned (wrong orientation) but the person used Photo viewer bundled with windows 10 to correct the orientation on their windows pc.

There is a couple of solutions for this, as its a common issue.

Also try out the latest image extension, it includes a new engine, twelve monkeys, it may help!

1 Like

Thank you so much Zackster, the upgrades did it :star_struck:
I was able to solve the problem. After I upgraded Lucee to version 5.3.9.133 and the Image Extension to 1.2.0.0 Snapshot, all previously incorrectly recognized photos were recognized in the correct orientation.

I use the following configuration in my production environment:
OS: Debian 11.03
Java version: 17.0.3
Tomcat version: 9.0.43
Lucee version: 5.3.9.133
Image Extension 1.2.0.0 Snapshot

Thank you all! You have really helped me a lot!

2 Likes

that’s really awesome, yeah :slight_smile:

tho, keep in mind, java 17 isn’t fully supported yet

1 Like