diff options
author | Thomas BrĂ¼derli | 2011-09-19 12:38:01 +0000 |
---|---|---|
committer | Thomas BrĂ¼derli | 2011-09-19 12:38:01 +0000 |
commit | 874bf803764e83a6b40d20e9c1d63f30573be8da (patch) | |
tree | fc3c59bc1987dff9137e1cedb21b389d1599a567 | |
parent | bb1b1a8b88e356dbd4a3e8e0c279a24624630ef7 (diff) | |
download | itools-874bf803764e83a6b40d20e9c1d63f30573be8da.tar.gz itools-874bf803764e83a6b40d20e9c1d63f30573be8da.tar.bz2 itools-874bf803764e83a6b40d20e9c1d63f30573be8da.zip |
Emulate -auto-rotate option from ImageMagick
-rw-r--r-- | it.class | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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']; |