Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #196 from AnthonySterling/interlace-support

Implemented interlace support for GD, Imagick, and Gmagick.
  • Loading branch information...
commit 990b7bac87b5ac1f47a40e860eef7ca67a6e4396 2 parents f6eb704 + f9df468
@avalanche123 authored
View
21 lib/Imagine/Gd/Image.php
@@ -479,6 +479,27 @@ public function layers()
return $this->layers;
}
+
+ /**
+ * {@inheritdoc}
+ **/
+ public function interlace($scheme)
+ {
+ static $supportedInterlaceSchemes = array(
+ ImageInterface::INTERLACE_NONE => 0,
+ ImageInterface::INTERLACE_LINE => 1,
+ ImageInterface::INTERLACE_PLANE => 1,
+ ImageInterface::INTERLACE_PARTITION => 1,
+ );
+
+ if (!array_key_exists($scheme, $supportedInterlaceSchemes)) {
+ throw new InvalidArgumentException('Unsupported interlace type');
+ }
+
+ imageinterlace($this->resource, $supportedInterlaceSchemes[$scheme]);
+
+ return $this;
+ }
/**
* Internal
View
21 lib/Imagine/Gmagick/Image.php
@@ -542,6 +542,27 @@ public function layers()
{
return $this->layers;
}
+
+ /**
+ * {@inheritdoc}
+ **/
+ public function interlace($scheme)
+ {
+ static $supportedInterlaceSchemes = array(
+ ImageInterface::INTERLACE_NONE => \Gmagick::INTERLACE_NO,
+ ImageInterface::INTERLACE_LINE => \Gmagick::INTERLACE_LINE,
+ ImageInterface::INTERLACE_PLANE => \Gmagick::INTERLACE_PLANE,
+ ImageInterface::INTERLACE_PARTITION => \Gmagick::INTERLACE_PARTITION,
+ );
+
+ if (!array_key_exists($scheme, $supportedInterlaceSchemes)) {
+ throw new InvalidArgumentException('Unsupported interlace type');
+ }
+
+ $this->gmagick->setInterlaceScheme($supportedInterlaceSchemes[$scheme]);
+
+ return $this;
+ }
/**
* Internal
View
16 lib/Imagine/Image/ImageInterface.php
@@ -26,6 +26,11 @@
{
const RESOLUTION_PIXELSPERINCH = 'ppi';
const RESOLUTION_PIXELSPERCENTIMETER = 'ppc';
+
+ const INTERLACE_NONE = 'none';
+ const INTERLACE_LINE = 'line';
+ const INTERLACE_PLANE = 'plane';
+ const INTERLACE_PARTITION = 'partition';
/**
* Returns the image content as a binary string
@@ -102,4 +107,15 @@ public function getColorAt(PointInterface $point);
* @return LayersInterface
*/
public function layers();
+
+ /**
+ * Enables or disables interlacing
+ *
+ * @param string $scheme
+ *
+ * @throws InvalidArgumentException When an unsupported Interface type is supplied
+ *
+ * @return ImageInterface
+ */
+ public function interlace($scheme);
}
View
21 lib/Imagine/Imagick/Image.php
@@ -281,6 +281,27 @@ public function get($format, array $options = array())
return $this->imagick->getImagesBlob();
}
+
+ /**
+ * {@inheritdoc}
+ **/
+ public function interlace($scheme)
+ {
+ static $supportedInterlaceSchemes = array(
+ ImageInterface::INTERLACE_NONE => \Imagick::INTERLACE_NO,
+ ImageInterface::INTERLACE_LINE => \Imagick::INTERLACE_LINE,
+ ImageInterface::INTERLACE_PLANE => \Imagick::INTERLACE_PLANE,
+ ImageInterface::INTERLACE_PARTITION => \Imagick::INTERLACE_PARTITION,
+ );
+
+ if (!array_key_exists($scheme, $supportedInterlaceSchemes)) {
+ throw new InvalidArgumentException('Unsupported interlace type');
+ }
+
+ $this->imagick->setInterlaceScheme($supportedInterlaceSchemes[$scheme]);
+
+ return $this;
+ }
/**
* @param array $options
Please sign in to comment.
Something went wrong with that request. Please try again.