aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2012-04-01 00:02:36 +0000
committerplegall <plg@piwigo.org>2012-04-01 00:02:36 +0000
commit2ec7183adb37f910f96b29ed148ca6ae2bc385b9 (patch)
treec20d0873a06233f15f039848457265d1d96936ea /admin/include
parent3a76852f0ce5573585fd70623321d8cb7e736ab3 (diff)
feature 2604: support rotation on derivatives
git-svn-id: http://piwigo.org/svn/trunk@13843 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include')
-rw-r--r--admin/include/functions_upload.inc.php7
-rw-r--r--admin/include/image.class.php32
2 files changed, 36 insertions, 3 deletions
diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php
index 2a5206c1b..19482ee02 100644
--- a/admin/include/functions_upload.inc.php
+++ b/admin/include/functions_upload.inc.php
@@ -269,6 +269,11 @@ SELECT
}
}
+ // we need to save the rotation angle in the database to compute
+ // width/height of "multisizes"
+ $rotation_angle = pwg_image::get_rotation_angle($file_path);
+ $rotation = pwg_image::get_rotation_code_from_angle($rotation_angle);
+
$file_infos = pwg_image_infos($file_path);
if (isset($image_id))
@@ -280,6 +285,7 @@ SELECT
'height' => $file_infos['height'],
'md5sum' => $md5sum,
'added_by' => $user['id'],
+ 'rotation' => $rotation,
);
if (isset($level))
@@ -307,6 +313,7 @@ SELECT
'height' => $file_infos['height'],
'md5sum' => $md5sum,
'added_by' => $user['id'],
+ 'rotation' => $rotation,
);
if (isset($level))
diff --git a/admin/include/image.class.php b/admin/include/image.class.php
index 30e62de1d..61b1ab277 100644
--- a/admin/include/image.class.php
+++ b/admin/include/image.class.php
@@ -238,7 +238,7 @@ class pwg_image
return null;
}
- $rotation = null;
+ $rotation = 0;
$exif = exif_read_data($source_filepath);
@@ -262,6 +262,28 @@ class pwg_image
return $rotation;
}
+ static function get_rotation_code_from_angle($rotation_angle)
+ {
+ switch($rotation_angle)
+ {
+ case 0: return 0;
+ case 90: return 1;
+ case 180: return 2;
+ case 270: return 3;
+ }
+ }
+
+ static function get_rotation_angle_from_code($rotation_code)
+ {
+ switch($rotation_code)
+ {
+ case 0: return 0;
+ case 1: return 90;
+ case 2: return 180;
+ case 3: return 270;
+ }
+ }
+
/** Returns a normalized convolution kernel for sharpening*/
static function get_sharpen_matrix($amount)
{
@@ -423,11 +445,15 @@ class image_imagick implements imageInterface
function resize($width, $height)
{
$this->image->setInterlaceScheme(Imagick::INTERLACE_LINE);
- if ($this->get_width()%2 == 0 && $this->get_height()%2 == 0
- && $this->get_width() > 3*$width)
+
+ // TODO need to explain this condition
+ if ($this->get_width()%2 == 0
+ && $this->get_height()%2 == 0
+ && $this->get_width() > 3*$width)
{
$this->image->scaleImage($this->get_width()/2, $this->get_height()/2);
}
+
return $this->image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 0.9);
}