Copied to clipboard

Flag this post as spam?

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


  • Manfred Klinger 12 posts 82 karma points
    Jul 27, 2023 @ 08:07
    Manfred Klinger
    0

    Crops with webp, remove exif data

    We are using image croppers and convert our images to webp. This is done by using a static helper class which we used in many projects before. However, there are some pictures which are just randomly rotated by 90 degrees. It seems like this has something to do with exif data, since it was taken on a mobile phone and then rotated there.

    Our Helper looks like this:

    public static class ImageHelper {
        public static string? GetOptimisedCropUrl(this IPublishedContent? image, string crop) {
            if (image == null) {
                return null;
            }
    
            // return image with set crop if crop is set
            if (!string.IsNullOrWhiteSpace(crop)) return image.GetCropUrl(crop) + "&format=webp";
    
            // else, get image height and width and set as crop
            var imageHeight = image.GetProperty("umbracoHeight")?.GetValue()?.SafeCast<int>();
            var imageWidth = image.GetProperty("umbracoWidth")?.GetValue()?.SafeCast<int>();
    
            // if image is larger than 2560 x 1440, set large crop
            if (imageHeight is >= 1440 && imageWidth is >= 2560) {
                return image.GetCropUrl("LargeImageCrop") + "&format=webp";
            }
            return image.Url() + "?width=" + imageWidth + "&height=" + imageHeight + "&format=webp";
        }
    }
    

    We tried a couple of settings from https://docs.sixlabors.com/articles/imagesharp.web/processingcommands.html like orient or compand, but it does not change anything.

    Is there any way to remove exif data or otherwise solve the rotation problem without installing any sort of addon/extension?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jul 27, 2023 @ 13:16
    Huw Reddick
    0

    I had the same issue when trying to use but just gave up and removed the format :) then they flip correctly. Not much help I'm afraid.

Please Sign in or register to post replies

Write your reply to:

Draft