From 874bf803764e83a6b40d20e9c1d63f30573be8da Mon Sep 17 00:00:00 2001 From: Thomas BrĂ¼derli Date: Mon, 19 Sep 2011 12:38:01 +0000 Subject: Emulate -auto-rotate option from ImageMagick --- it.class | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'it.class') 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']; -- cgit v1.2.3