Giter VIP home page Giter VIP logo

Comments (23)

ausi avatar ausi commented on September 17, 2024 1

I'm not sure where it should be integrated.

I'm not either.

Either the images should be rotated to the right orientation during the upload process

But this would modify the original file and re-encode the JPEG data. Is that always desired?

or the orientation should be taken into account with each resize.

This would make the resized images behave differently in the browser than the original file does. And we would also have to adapt all calls to getimagesize() and rotate the values.

Sadly browsers themselves are inconsistent in handling this topic, see https://caniuse.com/#feat=css-image-orientation

I think the best option would be to make it optional. Either via a Setting like “Auto-rotate images on upload” or by adding a „repair“ button next to EXIF images in the file manager.

from image.

ausi avatar ausi commented on September 17, 2024 1

Either via a Setting like “Auto-rotate images on upload” or by adding a „repair“ button next to EXIF images in the file manager.

@contao/developers What do you think?

from image.

ausi avatar ausi commented on September 17, 2024 1

AFAIR we agreed that we don’t want to create an image editing software inside Contao. If we add a rotate feature we might also add cropping, resizing, contrast and many more.

I think the best solution would be to auto-rotate images on upload (based on the EXIF data) and make it possible to opt out with a global setting.

from image.

fritzmg avatar fritzmg commented on September 17, 2024 1

Only having an option to manually rotate an image wouldn't suffice - if your application accepts user uploaded images, that are then immediately displayed on the website.

from image.

ausi avatar ausi commented on September 17, 2024 1
  1. Always consider the EXIF orientation during resizing.

The longer I’m thinking about it, the more appealing it looks to me. We just have to run the lightbox images through the resizer too, and if it detects an EXIF orientation it should generate a rotated image instead of returning the original.

Should be fairly simple to implement in

image/src/Resizer.php

Lines 139 to 142 in 93d47eb

// Skip resizing if it would have no effect
if (!$image->getDimensions()->isRelative() && $coordinates->isEqualTo($image->getDimensions()->getSize())) {
return $this->createImage($image, $image->getPath());
}

from image.

Toflar avatar Toflar commented on September 17, 2024

I think auto rotation might confuse users who have no clue about EXIF. A repair button next to the image would allow us to provide additional information. A separate view could even allow for a setting where you could configure whether the original should be replaced or not etc.

from image.

leofeyer avatar leofeyer commented on September 17, 2024

+1 for always using the auto-rotate information if it is present. I cannot think of a use case where you would want to use a wrongly rotated image.

from image.

fritzmg avatar fritzmg commented on September 17, 2024

I think a repair button would be insufficient. Consider this use case: you provide a front end form with a file upload, where you directly upload an image from your smartphone camera. This uploaded file will then be shown directly in the front end - but it might have the wrong orientation.

In this case an option for the file upload form field to automatically transform the image would be the most practical one I think.

from image.

fritzmg avatar fritzmg commented on September 17, 2024

Rotating the image only during image resize would be insufficient, if you show the original image in a lightbox for example (e.g. through Contao's own text, image and gallery content element for example).

from image.

ausi avatar ausi commented on September 17, 2024

In this case an option for the file upload form field to automatically transform the image would be the most practical one I think.

I think a global setting that affects all image uploads should be sufficient, don’t you think?

from image.

fritzmg avatar fritzmg commented on September 17, 2024

Fine by me. I personally can't think of a use case where I would want to keep the original image anyway :)

from image.

aschempp avatar aschempp commented on September 17, 2024

Why not simply add a rotate feature? This would also allow to fix images that do not have EXIF data but are incorrectly rotated.

from image.

agoat avatar agoat commented on September 17, 2024

I think the best solution would be to auto-rotate images on upload (based on the EXIF data) and make it possible to opt out with a global setting.

Maybe we should add a switch to respect the orientation from the EXIF data either during upload or image resizing (in the frontend).

I never let Contao resize images on upload. Always keep the original and resize for the frontend output.

For example the nextcloud project saves the original images (as the goal is to share files) but shows an preview for jpg files. And that's pretty fast.

So I recommend a global setting to fix(?) orientation during upload (based on EXIF data, but then the EXIF data will be lost or have to be rewritten) or store the (resized) image with orignal orientation (with original EXIF data) and take the orientation into account when resizing in the frontend.

from image.

ausi avatar ausi commented on September 17, 2024

or store the (resized) image with orignal orientation (with original EXIF data) and take the orientation into account when resizing in the frontend.

This would not work well, see #44 (comment) and #44 (comment)

from image.

agoat avatar agoat commented on September 17, 2024

This would not work well, see #44 (comment) and #44 (comment)

If I'm going to show the original (uploaded) image, then I should resize and orientate images during upload (as I would do in my Imageprogram when preparing images for the web). We can't cover every situation.

IMO the orientation information of an image should always be used when resizing - which is the same as building a new image (without EXIF) from the original (with EXIF), but with different dimension. See also #44 (comment).

Maybe it's enough to have it optional to 'auto-rotate' images when resizing (if EXIF orientation info is present). This will happen when images are uploaded and(!) resized or when the images will be resized during frontend output.

from image.

fritzmg avatar fritzmg commented on September 17, 2024

If I'm going to show the original (uploaded) image, then I should resize and orientate images during upload (as I would do in my Imageprogram when preparing images for the web). We can't cover every situation.

Uploading an image via the front end form and then displaying all uploaded images in a gallery content element should be a fairly straight forward use case. And for this case the original image must be transformed directly after uploading.

from image.

agoat avatar agoat commented on September 17, 2024

Uploading an image via the front end form and then displaying all uploaded images in a gallery content element should be a fairly straight forward use case

I don't see a problem here.
If 'auto-rotation' is enabled and images will be resized during upload, all fixed.
If 'auto-rotation' is enabled and images will not be resized during upload but(!) a resized preview image will be shown in a gallery content element, fixed too.

If the original image is shown directly then you have to be sure all images (with EXIF orientation) have to be resized.
But a forced orientation transform when uploading images (whether they are resized or not) should be avoided, because there will be ever a loss of quality. For this use case we can add an extra option in the front end upload form/module.

from image.

fritzmg avatar fritzmg commented on September 17, 2024

If 'auto-rotation' is enabled and images will not be resized during upload but(!) a resized preview image will be shown in a gallery content element, fixed too.

No, the image will be wrong in the lightbox.

from image.

agoat avatar agoat commented on September 17, 2024

I suggest the following.

  1. Always consider the EXIF orientation during resizing.
  2. Add an option to force re(orientation) on upload.

from image.

fritzmg avatar fritzmg commented on September 17, 2024
2\. Add an option to force re(orientation) on upload.

That's what we already suggested ;)

from image.

agoat avatar agoat commented on September 17, 2024

That's what we already suggested ;)

Well, then we're in agreement ;-)
Sometimes I'm somewhat sluggish in my head.

I just wanted to be sure that images could be uploaded without being changed automatically.

from image.

asaage avatar asaage commented on September 17, 2024

just stumbled about this css

#boxContent img {
  image-orientation: from-image;
}

Unfortunately not the greatest support yet https://caniuse.com/#feat=css-image-orientation :(
I'm not the biggest fan of irreversible altering user-uploaded content but an option might be ok.

from image.

ausi avatar ausi commented on September 17, 2024

Closed in favor of #52

from image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.