mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Interlace all output JPEG
Progressive images are both smaller and faster to load. Signed-off-by: Varun Patil <radialapps@gmail.com>
This commit is contained in:
parent
be892d2e28
commit
48917e718e
2 changed files with 6 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue