Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jose Badia 13 posts 156 karma points
    Sep 11, 2015 @ 20:55
    Jose Badia
    0

    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)

  • James Jackson-South 489 posts 1747 karma points c-trib
    Sep 12, 2015 @ 08:47
    James Jackson-South
    0

    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.

  • Jose Badia 13 posts 156 karma points
    Sep 12, 2015 @ 11:17
    Jose Badia
    0

    Thanks for your help, James. Here's one of the images (purposely blurred). I have used paint.net to edit some of these images. enter image description here

  • James Jackson-South 489 posts 1747 karma points c-trib
    Sep 14, 2015 @ 03:46
    James Jackson-South
    0

    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)

  • Jose Badia 13 posts 156 karma points
    Sep 15, 2015 @ 19:21
    Jose Badia
    0

    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.

    headshot resaved without exif

    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?

  • James Jackson-South 489 posts 1747 karma points c-trib
    Sep 15, 2015 @ 23:52
    James Jackson-South
    2

    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

Please Sign in or register to post replies

Write your reply to:

Draft