summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php63
1 files changed, 47 insertions, 16 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 03fe9d4..c811720 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -1124,26 +1124,26 @@ class PHPFSPOT {
$meta = $this->get_meta_informations($orig_image);
$rotate = 0;
- $flip = false;
+ $flip_hori = false;
+ $flip_vert = false;
switch($meta['Orientation']) {
-
case 1: /* top, left */
- $rotate = 0; $flip = false; break;
+ /* nothing to do */ break;
case 2: /* top, right */
- $rotate = 0; $flip = true; break;
+ $rotate = 0; $flip_hori = true; break;
case 3: /* bottom, left */
- $rotate = 180; $flip = false; break;
+ $rotate = 180; break;
case 4: /* bottom, right */
- $rotate = 180; $flip = true; break;
+ $flip_vert = true; break;
case 5: /* left side, top */
- $rotate = 90; $flip = true; break;
+ $rotate = 90; $flip_vert = true; break;
case 6: /* right side, top */
- $rotate = 90; $flip = false; break;
+ $rotate = 90; break;
case 7: /* left side, bottom */
- $rotate = 270; $flip = true; break;
+ $rotate = 270; $flip_vert = true; break;
case 8: /* right side, bottom */
- $rotate = 270; $flip = false; break;
+ $rotate = 270; break;
}
$src_img = @imagecreatefromjpeg($orig_image);
@@ -1215,12 +1215,14 @@ class PHPFSPOT {
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img));
/* needs the image to be flipped horizontal? */
- if($flip) {
- print "(FLIP)";
- $image = $dst_img;
- for($x = 0; $x < $new_w; $x++) {
- imagecopy($dst_img, $image, $x, 0, $w - $x - 1, 0, 1, $h);
- }
+ if($flip_hori) {
+ $this->_debug("(FLIP)");
+ $dst_img = $this->flipImage($dst_img, 'hori');
+ }
+ /* needs the image to be flipped vertical? */
+ if($flip_vert) {
+ $this->_debug("(FLIP)");
+ $dst_img = $this->flipImage($dst_img, 'vert');
}
if($rotate) {
@@ -1537,6 +1539,35 @@ class PHPFSPOT {
} // rotateImage()
/**
+ * returns flipped image
+ *
+ * this function will return an either horizontal or
+ * vertical flipped truecolor image.
+ */
+ private function flipImage($image, $mode)
+ {
+ $w = imagesx($image);
+ $h = imagesy($image);
+ $flipped = imagecreatetruecolor($w, $h);
+
+ switch($mode) {
+ case 'vert':
+ for ($y = 0; $y < $h; $y++) {
+ imagecopy($flipped, $image, 0, $y, 0, $h - $y - 1, $w, 1);
+ }
+ break;
+ case 'hori':
+ for ($x = 0; $x < $w; $x++) {
+ imagecopy($flipped, $image, $x, 0, $w - $x - 1, 0, 1, $h);
+ }
+ break;
+ }
+
+ return $flipped;
+
+ } // flipImage()
+
+ /**
* return all assigned tags for the specified photo
*/
private function get_photo_tags($idx)