Add support for JPEG XL image format#41058
Hidden character warning
Conversation
apps/dav/lib/Avatars/AvatarNode.php
Outdated
| ob_start(); | ||
| if ($this->ext === 'png') { | ||
| imagepng($res); | ||
| } else if ($this->ext === 'jxl') { |
There was a problem hiding this comment.
| } else if ($this->ext === 'jxl') { | |
| } elseif ($this->ext === 'jxl') { |
|
Looks like browser support is really not there for jxl: https://caniuse.com/jpegxl So this would likely lead to broken images for everyone but Safar users if we support it. |
|
Thorium supports JPEG XL OOB. I am waiting for the day when Google will reverse that mistaken decision. https://bugs.chromium.org/p/chromium/issues/detail?id=1451807 |
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
|
BTW JPEG XL could be transparently converted to JPEG on the fly in order to save server storage space. |
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
We can just add support for previewing JXL files (all previews are png in the browser) for now, but not support handling it in other places as this PR tries to do. Just like Krita files for instance. |
Signed-off-by: Peter Kovář <peter.kovar@reflexion.tv>
| if ($this->ext === 'png') { | ||
| imagepng($res); | ||
| } elseif ($this->ext === 'jxl') { | ||
| imagejxl($res); |
Check failure
Code scanning / Psalm
UndefinedFunction
| throw new \Exception('Could not recompress background image as JPEG'); | ||
| } | ||
| } else if (str_contains($detectedMimeType, 'image/jxl')) { | ||
| if (!imagejxl($outputImage, $newTmpFile, 90)) { |
Check failure
Code scanning / Psalm
UndefinedFunction
| $imageType = IMAGETYPE_JPEG; | ||
| break; | ||
| case 'image/jxl': | ||
| $imageType = IMAGETYPE_JXL; |
Check failure
Code scanning / Psalm
UndefinedConstant
| imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); | ||
| $retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); | ||
| break; | ||
| case IMAGETYPE_JXL: |
Check failure
Code scanning / Psalm
UndefinedConstant
| $retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); | ||
| break; | ||
| case IMAGETYPE_JXL: | ||
| $retVal = imagejxl($this->resource, $filePath, $this->getJxlQuality()); |
Check failure
Code scanning / Psalm
UndefinedFunction
| $retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); | ||
| break; | ||
| case IMAGETYPE_JXL: | ||
| $retVal = imagejxl($this->resource, $filePath, $this->getJxlQuality()); |
Check failure
Code scanning / Psalm
UndefinedMethod
| $res = imagejpeg($this->resource, null, $quality); | ||
| break; | ||
| case "image/jxl": | ||
| $quality = $this->getJxlQuality(); |
Check failure
Code scanning / Psalm
UndefinedMethod
| break; | ||
| case "image/jxl": | ||
| $quality = $this->getJxlQuality(); | ||
| $res = imagejxl($this->resource, null, $quality); |
Check failure
Code scanning / Psalm
UndefinedFunction
|
I will check and try to add JPEG XL preview if the browser advertizes image/jxl support ASAP. |
| imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); | ||
| $retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); | ||
| break; | ||
| case IMAGETYPE_JXL: |
There was a problem hiding this comment.
Our OC_Image class is a wrapper for php's gd extension. The constant IMAGETYPE_JXL or the function imagejxl can only exist if the gd library get's support for jxl. libgd -> php-gd -> OC_Image.
Upstream feature request: libgd/libgd#699
|
I am still working locally on the GD library JPEG XL support. Will commit ASAP. I apologize for the noise. |
|
Thank you for your efforts in moving this topic forward 👍 |
|
@1div0 any news regarding the GD library JPEG XL support ? :) |
|
0 ATM, maybe next year++ |
JPEG XL support
This PR is intended for adding support of the JPEG XL image format in the Nextcloud.