Skip to content

Commit

Permalink
Merge pull request #19 from xpyctt/interlace
Browse files Browse the repository at this point in the history
Add interlace for progressive images
  • Loading branch information
yurkinx authored Jan 23, 2019
2 parents 2737b1e + 1810924 commit d1e1ea3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions yii/image/drivers/Kohana/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,23 @@ public function save($file = NULL, $quality = 100)
return $this->_do_save($file, $quality);
}

/**
* Enable or disable interlace for progressive images
*
* GD
* Just use true or false for enable or disable interlace for jpeg files.
*
* Imagick
* Use INTERLACE constants from http://php.net/manual/en/imagick.constants.php
*
* @param $scheme bool|int
* @return mixed
*/
public function interlace($scheme)
{
return $this->_do_interlace($scheme);
}

/**
* Render the image and return the binary string.
*
Expand Down Expand Up @@ -832,4 +849,12 @@ abstract protected function _do_save($file, $quality);
*/
abstract protected function _do_render($type, $quality);

/**
* Execute an interlace.
*
* @param $scheme
* @return mixed
*/
abstract protected function _do_interlace($scheme);

} // End Image
8 changes: 8 additions & 0 deletions yii/image/drivers/Kohana/Image/GD.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,4 +685,12 @@ protected function _create($width, $height)
return $image;
}

protected function _do_interlace($scheme)
{
// Loads image if not yet loaded
$this->_load_image();

return imageinterlace($this->_image, $scheme);
}

} // End Image_GD
5 changes: 5 additions & 0 deletions yii/image/drivers/Kohana/Image/Imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,9 @@ protected function _get_imagetype($extension)

return array($format, $type);
}

protected function _do_interlace($scheme)
{
return $this->im->setInterlaceScheme($scheme);
}
} // End Kohana_Image_Imagick

0 comments on commit d1e1ea3

Please sign in to comment.