diff options
author | Thomas BrĂ¼derli | 2012-06-18 13:14:21 +0000 |
---|---|---|
committer | Thomas BrĂ¼derli | 2012-06-18 13:14:21 +0000 |
commit | 5d3f9f0d2ba106d9992377d9f5a0ddb41db4de03 (patch) | |
tree | 24b9310a23ffa39784dd6d3bdb8bbef1bac05fa6 | |
parent | c03ebe57279751826e883373a63d12c8065b7556 (diff) | |
download | itools-5d3f9f0d2ba106d9992377d9f5a0ddb41db4de03.tar.gz itools-5d3f9f0d2ba106d9992377d9f5a0ddb41db4de03.tar.bz2 itools-5d3f9f0d2ba106d9992377d9f5a0ddb41db4de03.zip |
Add parameter to adjust jpeg quality
-rw-r--r-- | it.class | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -576,6 +576,7 @@ static function _exec_quotevalue($value, $errmsg = "") * @param $p['size'] Width x height of resulting image, e.g. "160x60" * @param $p['type'] Output file type, e.g. "jpg" * @param $p['types'] Comma separated list of accepted input types, default "bmp,eps,gif,jp2,jpg,png,svg,tif" + * @param $p['quality'] JPEG quality (0-100), default is 75 * @param $p['-opts'] Custom command line options to ImageMagick convert * @return Success of convert as true/false */ @@ -603,12 +604,12 @@ static function imageconvert($p) } $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']; + $p += array('type' => $type, 'types' => "bmp,eps,gif,jp2,jpg,png,svg,tif", 'quality' => 75); + $p['-opts'] = array('-thumbnail' => $p['size'], '-quality' => $p['quality']) + (array)$p['-opts']; $ultratimeout = file_exists("/opt/ultra/bin/ultratimeout") ? "/opt/ultra/bin/ultratimeout 30 " : ""; if (in_array($type, explode(',', $p['types']))) # Valid type? - $cmdoutput = it::exec($ultratimeout . 'gm convert 2>&1 -flatten -quality 75 {-opts} {in} {type}:{out} || echo "SHELL ERROR $?"', $p); + $cmdoutput = it::exec($ultratimeout . 'gm convert 2>&1 -flatten {-opts} {in} {type}:{out} || echo "SHELL ERROR $?"', $p); return $cmdoutput === ""; } |