Permalink
Browse files

Merge pull request #191 from hisamu/develop

Implementing sharpen effect
  • Loading branch information...
2 parents edc2e77 + eaa0b7f commit f6eb70401ed5c7462994db331fb9e63efba27871 @avalanche123 committed Jan 29, 2013
@@ -57,4 +57,13 @@ public function grayscale();
* @throws RuntimeException
*/
public function colorize(Color $color);
+
+ /**
+ * Sharpens the image
+ *
+ * @return EffectsInterface
+ *
+ * @throws RuntimeException
+ */
+ public function sharpen();
}
View
@@ -74,4 +74,19 @@ public function colorize(Color $color)
return $this;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sharpen()
+ {
+ $sharpenMatrix = array(array(-1,-1,-1), array(-1,16,-1), array(-1,-1,-1));
+ $divisor = array_sum(array_map('array_sum', $sharpenMatrix));
+
+ if (false === imageconvolution($this->resource, $sharpenMatrix, $divisor, 0)) {
+ throw new RuntimeException('Failed to sharpen the image');
+ }
+
+ return $this;
+ }
}
@@ -81,4 +81,12 @@ public function colorize(Color $color)
{
throw new RuntimeException('Gmagick does not support colorize');
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sharpen()
+ {
+ throw new RuntimeException('Gmagick does not support sharpen yet');
+ }
}
@@ -82,4 +82,18 @@ public function colorize(Color $color)
return $this;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sharpen()
+ {
+ try {
+ $this->imagick->sharpenImage(2, 1);
+ } catch (\ImagickException $e) {
+ throw new RuntimeException('Failed to sharpen the image');
+ }
+
+ return $this;
+ }
}

0 comments on commit f6eb704

Please sign in to comment.