]> source.dussan.org Git - nextcloud-server.git/commitdiff
Interlace all output JPEG 34678/head
authorVarun Patil <radialapps@gmail.com>
Wed, 19 Oct 2022 21:42:42 +0000 (14:42 -0700)
committerVarun Patil <varunpatil@ucla.edu>
Tue, 25 Oct 2022 16:40:20 +0000 (09:40 -0700)
Progressive images are both smaller and faster to load.

Signed-off-by: Varun Patil <radialapps@gmail.com>
lib/private/legacy/OC_Image.php
tests/lib/ImageTest.php

index a212d6390848ccac37c917dd9edb5d0ab2ff9a1c..45584b7209a090b4c74914032b1a3cb0d7bc499d 100644 (file)
@@ -290,6 +290,8 @@ class OC_Image implements \OCP\IImage {
                                $retVal = imagegif($this->resource, $filePath);
                                break;
                        case IMAGETYPE_JPEG:
+                               /** @psalm-suppress InvalidScalarArgument */
+                               imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1));
                                $retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality());
                                break;
                        case IMAGETYPE_PNG:
@@ -379,6 +381,8 @@ class OC_Image implements \OCP\IImage {
                                $res = imagepng($this->resource);
                                break;
                        case "image/jpeg":
+                               /** @psalm-suppress InvalidScalarArgument */
+                               imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1));
                                $quality = $this->getJpegQuality();
                                if ($quality !== null) {
                                        $res = imagejpeg($this->resource, null, $quality);
index e6818c7e24359c2b963bd9659a9954dead7909b6..c843d5f5eb9753e34abca033d1d59fb01f27d246 100644 (file)
@@ -149,6 +149,8 @@ class ImageTest extends \Test\TestCase {
                $img = new \OC_Image(null, null, $config);
                $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.jpg');
                $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+               /** @psalm-suppress InvalidScalarArgument */
+               imageinterlace($raw, (PHP_VERSION_ID >= 80000 ? true : 1));
                ob_start();
                imagejpeg($raw);
                $expected = ob_get_clean();