Skip to content
Browse files

Merge branch 'development' of github.com:photo/frontend into development

Conflicts:
	src/libraries/adapters/ImageAbstract.php
	src/libraries/adapters/ImageGD.php
  • Loading branch information...
2 parents bec755d + e1a53c9 commit 158a5284f52cfa6d7cb224e2ffaf3a23083e2919 @jmathai jmathai committed Aug 20, 2014
View
1 src/libraries/adapters/ImageAbstract.php
@@ -14,6 +14,7 @@
abstract public function scale($width, $height, $maintainAspectRatio = true);
abstract public function greyscale();
abstract public function write($outputFile, $format = '');
+ abstract public function setCompressionQuality($quality);
public function __construct()
{
View
14 src/libraries/adapters/ImageGD.php
@@ -25,6 +25,7 @@ class ImageGD extends ImageAbstract
private $type;
private $width;
private $height;
+ private $quality = 90;
/**
* Destructor.
@@ -146,6 +147,14 @@ public function greyscale()
}
/**
+ * Set compression quality
+ */
+ public function setCompressionQuality($quality)
+ {
+ $this->quality = (int) $quality;
+ }
+
+ /**
* Save modifications to the image to the file system
*
* @param string $outputFile The file to write the modifications to.
@@ -167,8 +176,7 @@ public function write($outputFile, $format = '')
imagepng($this->image, $outputFile, 9);
elseif($format == 'gif')
imagegif($this->image, $outputFile, 90);
- // tif ain't working on GD it seems.
- else
- imagejpeg($this->image, $outputFile, 90);
+ else // tif ain't working on GD it seems.
+ imagejpeg($this->image, $outputFile, $this->quality);
}
}
View
10 src/libraries/adapters/ImageGraphicsMagick.php
@@ -69,6 +69,16 @@ public function greyscale()
}
/**
+ * Set compression quality
+ */
+ public function setCompressionQuality($quality)
+ {
+ if (method_exists($this->image, 'setCompressionQuality')) {
+ $this->image->setCompressionQuality((int) $quality);
+ }
+ }
+
+ /**
* Save modifications to the image to the file system
*
* @param string $outputFile The file to write the modifications to.
View
10 src/libraries/adapters/ImageImageMagick.php
@@ -71,6 +71,16 @@ public function greyscale()
}
/**
+ * Set compression quality
+ */
+ public function setCompressionQuality($quality)
+ {
+ if (method_exists($this->image, 'setImageCompressionQuality')) {
+ $this->image->setImageCompressionQuality((int) $quality);
+ }
+ }
+
+ /**
* Save modifications to the image to the file system
*
* @param string $outputFile The file to write the modifications to.

0 comments on commit 158a528

Please sign in to comment.
Something went wrong with that request. Please try again.