-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JPEG XL image format #41058
base: master
Are you sure you want to change the base?
The head ref may contain hidden characters: "JPEG\u00A0XL"
Conversation
apps/dav/lib/Avatars/AvatarNode.php
Outdated
@@ -61,6 +61,8 @@ public function get() { | |||
ob_start(); | |||
if ($this->ext === 'png') { | |||
imagepng($res); | |||
} else if ($this->ext === 'jxl') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} 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>
@@ -61,6 +61,8 @@ | |||
ob_start(); | |||
if ($this->ext === 'png') { | |||
imagepng($res); | |||
} elseif ($this->ext === 'jxl') { | |||
imagejxl($res); |
Check failure
Code scanning / Psalm
UndefinedFunction
@@ -254,6 +254,10 @@ | |||
if (!imagejpeg($outputImage, $newTmpFile, 90)) { | |||
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
@@ -273,6 +273,9 @@ | |||
case 'image/jpeg': | |||
$imageType = IMAGETYPE_JPEG; | |||
break; | |||
case 'image/jxl': | |||
$imageType = IMAGETYPE_JXL; |
Check failure
Code scanning / Psalm
UndefinedConstant
@@ -297,6 +300,9 @@ | |||
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
@@ -297,6 +300,9 @@ | |||
imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); | |||
$retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); | |||
break; | |||
case IMAGETYPE_JXL: | |||
$retVal = imagejxl($this->resource, $filePath, $this->getJxlQuality()); |
Check failure
Code scanning / Psalm
UndefinedFunction
@@ -297,6 +300,9 @@ | |||
imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); | |||
$retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); | |||
break; | |||
case IMAGETYPE_JXL: | |||
$retVal = imagejxl($this->resource, $filePath, $this->getJxlQuality()); |
Check failure
Code scanning / Psalm
UndefinedMethod
@@ -388,6 +395,10 @@ | |||
$quality = $this->getJpegQuality(); | |||
$res = imagejpeg($this->resource, null, $quality); | |||
break; | |||
case "image/jxl": | |||
$quality = $this->getJxlQuality(); |
Check failure
Code scanning / Psalm
UndefinedMethod
@@ -388,6 +395,10 @@ | |||
$quality = $this->getJpegQuality(); | |||
$res = imagejpeg($this->resource, null, $quality); | |||
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. |
@@ -297,6 +300,9 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.