Incorrect image dimensions when uploading to media content
When I upload images to backoffice media content area, Umbraco sets the size incorrectly. For instance, my original JPEG images are 150 x 180, as confirmed in the Windows file property details. But when I upload this image, Umbraco says that the file is 3062 x 3838. Interestingly, the sizes of some of the image files are read correctly, but others are not. Is this a bug? Is there a workaround?
(Using Umbraco 7.2.8)
Hmm... Nothing iffy about that image however I'm suspecting that Paint.Net might be changing something. I take it there's no way you could link to an original so I can run some tests? Email me if need be (james_south at hotmail.com)
James, I think you're correct about EXIF. I opened the file that I had sent you earlier in paint.net. Then, I copied and pasted the entire image contents onto a new image, and saved the new image as a new JPEG. I think that this takes out the EXIF data. When I uploaded the resulting image into Umbraco, it finally picked up the correct size.
I would still like to better understand the difference between these two image files. Can you tell the difference? It is also difficult to understand why Umbraco doesn’t pick up the correct size. After an image has been cropped and resized, Umbraco should ignore the original size information that came from the camera. Is that a bug?
You're correct in assuming that copy/pasting the image into a new file will remove the EXIF data. You're also correct in your approach to working with jpeg's. Jpeg images apply a lossy compression technique that results in a loss of pixel information over time if constantly re-saved.
Now... As to whether the issue is a bug or not. Umbraco checks for and reads the EXIF data if available for images in order to ensure that an out of memory exception does not occur for very large images. Reading the EXIF data allows reading of only part of the image stream and is also a lot faster.
This is a good idea and has been correctly implemented.
The dimension metadata set in the image should actually match the width/height of your new image not the original so I believe the bug to be in whatever software you are using to resize the images.
Incorrect image dimensions when uploading to media content
When I upload images to backoffice media content area, Umbraco sets the size incorrectly. For instance, my original JPEG images are 150 x 180, as confirmed in the Windows file property details. But when I upload this image, Umbraco says that the file is 3062 x 3838. Interestingly, the sizes of some of the image files are read correctly, but others are not. Is this a bug? Is there a workaround? (Using Umbraco 7.2.8)
I believe that Umbraco checks EXIF metadata when determining the size of an image. I wonder if that is having an affect.
Could you perhaps upload one of the images in question so I can have a look? I should be able to figure out what is happening.
Thanks for your help, James. Here's one of the images (purposely blurred). I have used paint.net to edit some of these images.
Hmm... Nothing iffy about that image however I'm suspecting that Paint.Net might be changing something. I take it there's no way you could link to an original so I can run some tests? Email me if need be (james_south at hotmail.com)
James, I think you're correct about EXIF. I opened the file that I had sent you earlier in paint.net. Then, I copied and pasted the entire image contents onto a new image, and saved the new image as a new JPEG. I think that this takes out the EXIF data. When I uploaded the resulting image into Umbraco, it finally picked up the correct size.
I would still like to better understand the difference between these two image files. Can you tell the difference? It is also difficult to understand why Umbraco doesn’t pick up the correct size. After an image has been cropped and resized, Umbraco should ignore the original size information that came from the camera. Is that a bug?
Hi Jose,
I quick look through the source and I've found the file that does the resizing and reporting back of image sizes.
https://github.com/umbraco/Umbraco-CMS/blob/7c4a189aa3cf583954defd9c43a3e55e325f2c3f/src/Umbraco.Core/Media/ImageHelper.cs
You're correct in assuming that copy/pasting the image into a new file will remove the EXIF data. You're also correct in your approach to working with jpeg's. Jpeg images apply a lossy compression technique that results in a loss of pixel information over time if constantly re-saved.
You can see an example of that here.
http://petapixel.com/2010/02/04/saving-jpeg-photos-hundreds-of-times/
Now... As to whether the issue is a bug or not. Umbraco checks for and reads the EXIF data if available for images in order to ensure that an out of memory exception does not occur for very large images. Reading the EXIF data allows reading of only part of the image stream and is also a lot faster.
This is a good idea and has been correctly implemented.
The dimension metadata set in the image should actually match the width/height of your new image not the original so I believe the bug to be in whatever software you are using to resize the images.
I hope that clears things up a little.
Cheers
James
is working on a reply...