summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas BrĂ¼derli2011-09-19 12:38:01 +0000
committerThomas BrĂ¼derli2011-09-19 12:38:01 +0000
commit874bf803764e83a6b40d20e9c1d63f30573be8da (patch)
treefc3c59bc1987dff9137e1cedb21b389d1599a567
parentbb1b1a8b88e356dbd4a3e8e0c279a24624630ef7 (diff)
downloaditools-874bf803764e83a6b40d20e9c1d63f30573be8da.tar.gz
itools-874bf803764e83a6b40d20e9c1d63f30573be8da.tar.bz2
itools-874bf803764e83a6b40d20e9c1d63f30573be8da.zip
Emulate -auto-rotate option from ImageMagick
-rw-r--r--it.class13
1 files changed, 13 insertions, 0 deletions
diff --git a/it.class b/it.class
index d18ca4f..262b295 100644
--- a/it.class
+++ b/it.class
@@ -546,6 +546,19 @@ static function imageconvert($p)
list(, $type) = explode(' ', strtolower(it::exec('identify 2>/dev/null {in}', $p))); # for things like eps
}
+ # emulate -auto-orient which is not supported by GM
+ if ($p['-opts']['-auto-orient']) {
+ $exif = @exif_read_data($p['in'], 'IFD0');
+ switch ($exif['Orientation']) {
+ case 2: $p['-opts']['-flop'] = true; break;
+ case 3: $p['-opts']['-rotate'] = 180; break;
+ case 4: $p['-opts']['-flip'] = true; break;
+ case 6: $p['-opts']['-rotate'] = 90; break;
+ case 8: $p['-opts']['-rotate'] = 270; break;
+ }
+ unset($p['-opts']['-auto-orient']);
+ }
+
$type = strtr($type, array("jpeg" => "jpg", "tiff" => "tif", "ps" => "eps", "ept" => "eps"));
$p += array('type' => $type, 'types' => "bmp,eps,gif,jp2,jpg,png,svg,tif");
$p['-opts'] = array('-thumbnail' => $p['size']) + (array)$p['-opts'];