From 81c838521be0811d3928cd7d103ac6b08b2f7fc5 Mon Sep 17 00:00:00 2001 From: Mitch Date: Tue, 24 Mar 2015 10:15:28 +1100 Subject: [PATCH] Basic image interlacing support --- README.md | 12 ++++++++++++ src/ImageResize.php | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 5f892c6..3f2432a 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,18 @@ $result = $image->getImageAsString(IMAGETYPE_PNG, 4); We're passing `null` for the image type in the example above to skip over it and provide the quality. In this case, the image type is assumed to be the same as the input. +Interlacing +----------- + +By default, [image interlacing](http://php.net/manual/en/function.imageinterlace.php) is turned off. It can be enabled by setting `$interlace` to `1`: + +```php +$image = new ImageResize('image.jpg'); +$image->scale(50); +$image->interlace = 1; +$image->save('image2.jpg') +``` + Chaining -------- diff --git a/src/ImageResize.php b/src/ImageResize.php index 995f9b2..cd79a75 100644 --- a/src/ImageResize.php +++ b/src/ImageResize.php @@ -19,6 +19,8 @@ class ImageResize public $quality_jpg = 75; public $quality_png = 0; + public $interlace = 0; + public $source_type; protected $source_image; @@ -108,6 +110,8 @@ public function save($filename, $image_type = null, $quality = null, $permission $dest_image = imagecreatetruecolor($this->getDestWidth(), $this->getDestHeight()); + imageinterlace($dest_image, $this->interlace); + switch ($image_type) { case IMAGETYPE_GIF: $background = imagecolorallocatealpha($dest_image, 255, 255, 255, 1);