diff options
author | Zvi ben Yaakov (a.k.a rdc) <coderzvi@infosoc.net> | 2012-06-19 23:29:24 +0300 |
---|---|---|
committer | Zvi ben Yaakov (a.k.a rdc) <coderzvi@infosoc.net> | 2012-06-19 23:29:24 +0300 |
commit | d20cdf09eafbc57c1b6dbcb78a5cdaa731ae876d (patch) | |
tree | 6308aca93a11587a579d4c4336cec14c9072151f /include/Photo.php | |
parent | 5b057e5dee09e0cab5b78bb9b2ac2e27d59a11f7 (diff) | |
parent | 79357ec60dd4338d25e0ddbbbfde38d5db541e67 (diff) | |
download | volse-hubzilla-d20cdf09eafbc57c1b6dbcb78a5cdaa731ae876d.tar.gz volse-hubzilla-d20cdf09eafbc57c1b6dbcb78a5cdaa731ae876d.tar.bz2 volse-hubzilla-d20cdf09eafbc57c1b6dbcb78a5cdaa731ae876d.zip |
Merge git://github.com/friendica/friendica
Diffstat (limited to 'include/Photo.php')
-rw-r--r-- | include/Photo.php | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/include/Photo.php b/include/Photo.php index aa6f5f113..3af1691ee 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -121,7 +121,70 @@ class Photo { $this->image = imagerotate($this->image,$degrees,0); $this->width = imagesx($this->image); $this->height = imagesy($this->image); - } + } + + public function flip($horiz = true, $vert = false) { + $w = imagesx($this->image); + $h = imagesy($this->image); + $flipped = imagecreate($w, $h); + if($horiz) { + for ($x = 0; $x < $w; $x++) { + imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h); + } + } + if($vert) { + for ($y = 0; $y < $h; $y++) { + imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1); + } + } + $this->image = $flipped; + } + + public function orient($filename) { + // based off comment on http://php.net/manual/en/function.imagerotate.php + + if(! function_exists('exif_read_data')) + return; + + $exif = exif_read_data($filename); + $ort = $exif['Orientation']; + + switch($ort) + { + case 1: // nothing + break; + + case 2: // horizontal flip + $this->flip(); + break; + + case 3: // 180 rotate left + $this->rotate(180); + break; + + case 4: // vertical flip + $this->flip(false, true); + break; + + case 5: // vertical flip + 90 rotate right + $this->flip(false, true); + $this->rotate(-90); + break; + + case 6: // 90 rotate right + $this->rotate(-90); + break; + + case 7: // horizontal flip + 90 rotate right + $this->flip(); + $this->rotate(-90); + break; + + case 8: // 90 rotate left + $this->rotate(90); + break; + } + } |