aboutsummaryrefslogtreecommitdiffstats
path: root/i.php
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 /i.php
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 'i.php')
-rw-r--r--i.php39
1 files changed, 35 insertions, 4 deletions
diff --git a/i.php b/i.php
index f59bf2aa9..5ecf831a0 100644
--- a/i.php
+++ b/i.php
@@ -444,7 +444,17 @@ if (strpos($page['src_location'], '/pwg_representative/')===false
{
try
{
- $query = 'SELECT coi, width, height FROM '.$prefixeTable.'images WHERE path=\''.$page['src_location'].'\'';
+ $query = '
+SELECT
+ id,
+ coi,
+ width,
+ height,
+ rotation
+ FROM '.$prefixeTable.'images
+ WHERE path=\''.$page['src_location'].'\'
+;';
+
if ( ($row=pwg_db_fetch_assoc(pwg_query($query))) )
{
if (isset($row['width']))
@@ -452,6 +462,24 @@ if (strpos($page['src_location'], '/pwg_representative/')===false
$page['original_size'] = array($row['width'],$row['height']);
}
$page['coi'] = $row['coi'];
+
+ include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php');
+
+ if (empty($row['rotation']))
+ {
+ $page['rotation_angle'] = pwg_image::get_rotation_angle($page['src_path']);
+
+ single_update(
+ $prefixeTable.'images',
+ array('rotation' => pwg_image::get_rotation_code_from_angle($page['rotation_angle'])),
+ array('id' => $row['id'])
+ );
+ }
+ else
+ {
+ $page['rotation_angle'] = pwg_image::get_rotation_angle_from_code($row['rotation']);
+ }
+
}
if (!$row)
{
@@ -472,8 +500,6 @@ if (!mkgetdir(dirname($page['derivative_path'])))
ierror("dir create error", 500);
}
-include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php');
-
ignore_user_abort(true);
set_time_limit(0);
@@ -482,7 +508,11 @@ $timing['load'] = time_step($step);
$changes = 0;
-// todo rotate
+// rotate
+if (0 != $page['rotation_angle'])
+{
+ $image->rotate($page['rotation_angle']);
+}
// Crop & scale
$o_size = $d_size = array($image->get_width(),$image->get_height());
@@ -554,6 +584,7 @@ if ($d_size[0]*$d_size[1] < 256000)
{// strip metadata for small images
$image->strip();
}
+
$image->set_compression_quality( $params->quality );
$image->write( $page['derivative_path'] );
$image->destroy();