aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Photo/PhotoDriver.php
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2019-02-11 23:59:43 +0100
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2019-02-14 22:06:42 +0100
commitb9df4c99cf9fcd1b16757309b4206ad084376aa2 (patch)
tree14cf94cc9c2c7f617ecc1b470d5ff5662dd38fb6 /Zotlabs/Photo/PhotoDriver.php
parente6dadb215e9e08491ae57ab851960a0973d3f704 (diff)
downloadvolse-hubzilla-b9df4c99cf9fcd1b16757309b4206ad084376aa2.tar.gz
volse-hubzilla-b9df4c99cf9fcd1b16757309b4206ad084376aa2.tar.bz2
volse-hubzilla-b9df4c99cf9fcd1b16757309b4206ad084376aa2.zip
Remove duplicate code in PhotoDriver classes.
cropImage is just a special case of cropImageRect, no need to duplicate all the code.
Diffstat (limited to 'Zotlabs/Photo/PhotoDriver.php')
-rw-r--r--Zotlabs/Photo/PhotoDriver.php34
1 files changed, 32 insertions, 2 deletions
diff --git a/Zotlabs/Photo/PhotoDriver.php b/Zotlabs/Photo/PhotoDriver.php
index e2e143f8d..c47a7c3b2 100644
--- a/Zotlabs/Photo/PhotoDriver.php
+++ b/Zotlabs/Photo/PhotoDriver.php
@@ -80,8 +80,18 @@ abstract class PhotoDriver {
abstract public function flip($horiz = true, $vert = false);
- abstract public function cropImage($max, $x, $y, $w, $h);
-
+ /**
+ * @brief Crops the image.
+ *
+ * @param int $maxx width of the new image
+ * @param int $maxy height of the new image
+ * @param int $x x-offset for region
+ * @param int $y y-offset for region
+ * @param int $w width of region
+ * @param int $h height of region
+ *
+ * @return boolean|void false on failure
+ */
abstract public function cropImageRect($maxx, $maxy, $x, $y, $w, $h);
/**
@@ -300,6 +310,26 @@ abstract class PhotoDriver {
}
/**
+ * @brief Crops a square image.
+ *
+ * @see cropImageRect()
+ *
+ * @param int $max size of the new image
+ * @param int $x x-offset for region
+ * @param int $y y-offset for region
+ * @param int $w width of region
+ * @param int $h height of region
+ *
+ * @return boolean|void false on failure
+ */
+ public function cropImage($max, $x, $y, $w, $h) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->cropImageRect($max, $max, $x, $y, $w, $h);
+ }
+
+ /**
* @brief Reads exif data from a given filename.
*
* @param string $filename