Page 1 of 1

JPEG image dimensions

Posted: Sat Mar 15, 2025 9:10 am
by magnussandstrom
Hi everyone,

I'm facing an issue while trying to retrieve image dimensions from a JPEG file in Switch. I need to calculate the dimensions by dividing the pixel count by the resolution and then display the result in a Checkpoint field.

For TIFF images, the following expression works:

[Switch.Calculation:Expression="round([Switch.Calculation:Expression="[Image.ImageWidth]/([Image.XResolution])"]*25.4)"]

However, this doesn't seem to work for JPEG images.

Does anyone know how to extract this information correctly for JPEG files in Switch? Any suggestions would be greatly appreciated!

Thanks!

Re: JPEG image dimensions

Posted: Sat Mar 15, 2025 9:57 am
by jan_suhr
Seems that it only works with TIFF,

https://www.enfocus.com/manuals/UserGui ... group.html

But try to extract the XMP data with the XMP Pickup tool, it might find what you need

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 8:04 am
by JimmyHartington
EDIT: Forget you needed the resolution as well. So this is NOT available in Stats.
But I let the answer stand if anybody needs the pixel-dimension of a jpg.

Could you instead use the info from Stats?
Image

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 8:25 am
by JimmyHartington
The resolution is possible to extract with Exiftool if you would not mind introducing another program.
Image

Updated with -b for trimming result from ExifTool.

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 9:10 am
by magnussandstrom
Yes, I installed exiftool the other day and can do it that way. I hoped there was a more straight forward solution.

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 9:17 am
by JimmyHartington
OK. Can I ask what the calculated value is used for?

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 9:27 am
by freddyp
Jimmy wrote that [Stats.PixelXDimension] does show the correct value for JPEG, but it also shows the correct value for TIFF files. Ergo, replace [Image.ImageWidth] by [Stats.PixelXDimension] in the calculation and it will work for both image types.

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 2:43 pm
by magnussandstrom
freddyp wrote: Mon Mar 17, 2025 9:27 am Jimmy wrote that [Stats.PixelXDimension] does show the correct value for JPEG, but it also shows the correct value for TIFF files. Ergo, replace [Image.ImageWidth] by [Stats.PixelXDimension] in the calculation and it will work for both image types.
Yes, but where can I find the resolution for a JPEG in Switch?

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 3:09 pm
by magnussandstrom
JimmyHartington wrote: Mon Mar 17, 2025 9:17 am OK. Can I ask what the calculated value is used for?
I have a flow for wallpaper-creating where I like to present the initial dimensions in a checkpoint before the next step, like this:

Skärmavbild 2025-03-17 kl. 15.06.44.png
Skärmavbild 2025-03-17 kl. 15.06.44.png (174.51 KiB) Viewed 82118 times

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 3:54 pm
by freddyp
Yes, but where can I find the resolution for a JPEG in Switch?
In [Image.XResolution] and [Image.YResolution]. If not, share the image so I can investigate.

Re: JPEG image dimensions

Posted: Mon Mar 17, 2025 4:42 pm
by jan_suhr
The XMP data for a JPEG looks like this in Photoshop

<tiff:XResolution>72/1</tiff:XResolution>
<tiff:YResolution>72/1</tiff:YResolution>

And in Switch it looks the same with [Image.XResolution] = 72/1 for a JPEG image.

Re: JPEG image dimensions

Posted: Tue Mar 18, 2025 1:08 pm
by magnussandstrom
freddyp wrote: Mon Mar 17, 2025 3:54 pm
Yes, but where can I find the resolution for a JPEG in Switch?
In [Image.XResolution] and [Image.YResolution]. If not, share the image so I can investigate.
It's seems like the JPEG images I trying with doesn't contain the meta data that Switch are looking for. Some JPGs works fine and other do not. I'll send you a "faulty" JPG Freddy.

Re: JPEG image dimensions

Posted: Fri Apr 04, 2025 1:14 pm
by bens
Yeah physical resolution is an optional tag in JPEG (and in many other image formats), so indeed not all files have it.