JPEG image dimensions
- magnussandstrom
- Advanced member
- Posts: 491
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
JPEG image dimensions
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!
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
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
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
- JimmyHartington
- Advanced member
- Posts: 419
- Joined: Tue Mar 22, 2011 7:38 am
Re: JPEG image dimensions
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?

But I let the answer stand if anybody needs the pixel-dimension of a jpg.
Could you instead use the info from Stats?
- JimmyHartington
- Advanced member
- Posts: 419
- Joined: Tue Mar 22, 2011 7:38 am
Re: JPEG image dimensions
The resolution is possible to extract with Exiftool if you would not mind introducing another program.

Updated with -b for trimming result from ExifTool.
Updated with -b for trimming result from ExifTool.
- magnussandstrom
- Advanced member
- Posts: 491
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: JPEG image dimensions
Yes, I installed exiftool the other day and can do it that way. I hoped there was a more straight forward solution.
- JimmyHartington
- Advanced member
- Posts: 419
- Joined: Tue Mar 22, 2011 7:38 am
Re: JPEG image dimensions
OK. Can I ask what the calculated value is used for?
Re: JPEG image dimensions
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.
- magnussandstrom
- Advanced member
- Posts: 491
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: JPEG image dimensions
Yes, but where can I find the resolution for a JPEG in Switch?
- magnussandstrom
- Advanced member
- Posts: 491
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: JPEG image dimensions
I have a flow for wallpaper-creating where I like to present the initial dimensions in a checkpoint before the next step, like this:JimmyHartington wrote: ↑Mon Mar 17, 2025 9:17 am OK. Can I ask what the calculated value is used for?
Re: JPEG image dimensions
In [Image.XResolution] and [Image.YResolution]. If not, share the image so I can investigate.Yes, but where can I find the resolution for a JPEG in Switch?
Re: JPEG image dimensions
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.
<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.
- magnussandstrom
- Advanced member
- Posts: 491
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: JPEG image dimensions
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
Yeah physical resolution is an optional tag in JPEG (and in many other image formats), so indeed not all files have it.