Search…

X3 Photo Gallery Support Forums

Search…
 
arbu
Topic Author
Posts: 5
Joined: 29 Sep 2020, 03:32

关于自动转变图片方向

02 May 2022, 03:44

为什么x3相册不能根据exif的数据来自动转变方向,我拍了竖版的图片通过ftp上传后显示竖版的并没有变成竖版,我记得files app 是可以自动转向的,为什么x3相册不可以呢?
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: 关于自动转变图片方向

02 May 2022, 05:36

This is a complicated issue.

Files app
Files app will detect image EXIF rotation on server/PHP (if server PHP supports reading EXIF) and forward the data to the Files app frontend. The files app frontend will then force CSS image-orientation: from-image so that the browser orients the image based on EXIF (if the browser supports image-orientation from EXIF). Furthermore, we also need to invert width and height so that width=height and height=width, else width and height is wrong and image looks skewed ... Although modern browsers can orient an image from EXIF, width and height provided from server are always from the physical orientation (which does not match EXIf orientation). Finally, we also need to create the resized image of course, in which case the resize is actually physically rotated to match EXIF and exif rotation is removed. Complex procedure.
demo.files.gallery/?tests/exif-image-orientation

X3
First of all, X3 was created before browser CSS image-orientation was a feature in modern browsers, and rotation-correction was therefore required from the uploader (or before uploading). There are already loads of X3 galleries with images rotated physically to match EXIF from the upload process, and what would happen if we now set CSS "image-orientation: from-image"? The browser will attempt to rotate images that might already be physically rotated, causing incorrectly rotated images. Also, width and height will be incorrect, because X3 can't really know for sure what is the correct orientation.

Therefore, because this could mess up existing X3 galleries, and because it is a complex procedure that requires EXIF on server and a browser that supports EXIF orientation, we can't risk or depend upon CSS image-orientation in X3. It will work like this in X4.

Browser-based image orientation is a relatively new feature as you can see. The website needs to know if the browser is able to rotate the image or not, because we need to assign width/height based on how the browser decides to rotate the image (or not).
https://developer.mozilla.org/en-US/doc ... patibility

--

这是一个复杂的问题。

文件应用
Files 应用程序将检测服务器/PHP 上的图像 EXIF 旋转(如果服务器 PHP 支持读取 EXIF)并将数据转发到 Files 应用程序前端。然后,文件应用程序前端将强制 CSS image-orientation: from-image 以便浏览器根据 EXIF 定位图像(如果浏览器支持来自 EXIF 的图像定位)。此外,我们还需要反转宽度和高度,以便宽度=高度和高度=宽度,否则宽度和高度是错误的,图像看起来会倾斜......虽然现代浏览器可以从 EXIF 定位图像,但服务器提供的宽度和高度是总是从物理方向(与 EXIf 方向不匹配)。最后,当然,我们还需要创建调整大小的图像,在这种情况下,调整大小实际上是物理旋转以匹配 EXIF,并且移除了 exif 旋转。复杂的程序。
demo.files.gallery/?tests/exif-image-orientation

X3
首先,X3 是在浏览器 CSS 图像方向是现代浏览器的一项功能之前创建的,因此需要上传者(或在上传之前)进行旋转校正。已经有很多 X3 画廊的图像经过物理旋转以匹配上传过程中的 EXIF,如果我们现在将 CSS 设置为“image-orientation: from-image”会发生什么?浏览器将尝试旋转可能已经物理旋转的图像,从而导致图像旋转不正确。此外,宽度和高度也会不正确,因为 X3 无法确定正确的方向。

因此,因为这可能会弄乱现有的 X3 画廊,并且因为它是一个复杂的过程,需要服务器上的 EXIF 和支持 EXIF 方向的浏览器,所以我们不能冒险或依赖 X3 中的 CSS 图像方向。它会在 X4 中像这样工作。

如您所见,基于浏览器的图像方向是一个相对较新的功能。网站需要知道浏览器是否能够旋转图像,因为我们需要根据浏览器决定旋转图像(或不旋转)的方式来分配宽度/高度。
https://developer.mozilla.org/en-US/doc ... patibility
 
arbu
Topic Author
Posts: 5
Joined: 29 Sep 2020, 03:32

Re: 关于自动转变图片方向

02 May 2022, 13:08

Thank you so much! I'm looking forward to the X4