JPEG image dimensions

Post Reply
User avatar
magnussandstrom
Advanced member
Posts: 491
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

JPEG image dimensions

Post 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!
jan_suhr
Advanced member
Posts: 677
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: JPEG image dimensions

Post 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
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
JimmyHartington
Advanced member
Posts: 419
Joined: Tue Mar 22, 2011 7:38 am

Re: JPEG image dimensions

Post 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
User avatar
JimmyHartington
Advanced member
Posts: 419
Joined: Tue Mar 22, 2011 7:38 am

Re: JPEG image dimensions

Post 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.
User avatar
magnussandstrom
Advanced member
Posts: 491
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: JPEG image dimensions

Post by magnussandstrom »

Yes, I installed exiftool the other day and can do it that way. I hoped there was a more straight forward solution.
User avatar
JimmyHartington
Advanced member
Posts: 419
Joined: Tue Mar 22, 2011 7:38 am

Re: JPEG image dimensions

Post by JimmyHartington »

OK. Can I ask what the calculated value is used for?
freddyp
Advanced member
Posts: 1120
Joined: Thu Feb 09, 2012 3:53 pm

Re: JPEG image dimensions

Post 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.
User avatar
magnussandstrom
Advanced member
Posts: 491
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: JPEG image dimensions

Post 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?
User avatar
magnussandstrom
Advanced member
Posts: 491
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: JPEG image dimensions

Post 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 16949 times
freddyp
Advanced member
Posts: 1120
Joined: Thu Feb 09, 2012 3:53 pm

Re: JPEG image dimensions

Post 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.
jan_suhr
Advanced member
Posts: 677
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: JPEG image dimensions

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
magnussandstrom
Advanced member
Posts: 491
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: JPEG image dimensions

Post 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.
bens
Advanced member
Posts: 279
Joined: Thu Mar 03, 2011 10:13 am

Re: JPEG image dimensions

Post by bens »

Yeah physical resolution is an optional tag in JPEG (and in many other image formats), so indeed not all files have it.
Post Reply