summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weber2010-01-15 16:48:44 +0000
committerChristian Weber2010-01-15 16:48:44 +0000
commit4e05f77a4a2de511de03269f5a8d20a1550d4014 (patch)
tree60e3f4a1e25d831e22b7b3ba31446f2a24bdcb05
parent940735ead52921744e1a8e531001333c8d7e26ea (diff)
downloaditools-4e05f77a4a2de511de03269f5a8d20a1550d4014.tar.gz
itools-4e05f77a4a2de511de03269f5a8d20a1550d4014.tar.bz2
itools-4e05f77a4a2de511de03269f5a8d20a1550d4014.zip
add support for EPS in imageconvert(), remove php4 cruft
-rw-r--r--it.class22
1 files changed, 9 insertions, 13 deletions
diff --git a/it.class b/it.class
index 20a3d34..d436537 100644
--- a/it.class
+++ b/it.class
@@ -506,31 +506,27 @@ static function _exec_quotevalue($value)
* @param $p['out'] Output filename (mandatory)
* @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 "gif,jpg,png,bmp,tif,jp2,svg"
+ * @param $p['types'] Comma separated list of accepted input types, default "bmp,eps,gif,jp2,jpg,png,svg,tif"
* @param $p['-opts'] Custom command line options to ImageMagick convert
* @return Success of convert as true/false
*/
static function imageconvert($p)
{
$result = false;
- $imagetype = @exif_imagetype($p['in']);
- if (!$imagetype && @get_class(it_xml::create(fopen($p['in'], "r"), array('prefix' => "_imageconvert_", 'safety' => 0))) == "_imageconvert_svg")
+ if (!(($imagetype = @exif_imagetype($p['in'])) && ($type = image_type_to_extension($imagetype, false))))
{
- # Accept SVG files if they are valid XML and root tag is svg
- $type = "svg";
- }
- else if (!function_exists("image_type_to_extension") || !($type = it::replace(array("jpeg" => "jpg", "tiff" => "tif"), image_type_to_extension($imagetype, false))))
- {
- # Fallback for PHP4
- $knowntypes = array(IMAGETYPE_GIF => "gif", IMAGETYPE_JPEG => "jpg", IMAGETYPE_PNG => "png", IMAGETYPE_BMP => "bmp");
- $type = $knowntypes[$imagetype];
+ if (@get_class(it_xml::create(fopen($p['in'], "r"), array('prefix' => "_imageconvert_", 'safety' => 0))) == "_imageconvert_svg")
+ $type = "svg"; # Accept SVG files if they are valid XML and root tag is svg
+ else
+ list(, $type) = explode(' ', strtolower(it::exec('identify {in}', $p))); # for things like eps
}
- $p += array('type' => $type, 'types' => "gif,jpg,png,bmp,tif,jp2,svg");
+ $type = strtr($type, "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'];
- if (it::match(",$type,", ",{$p['types']},")) # Valid type?
+ if (in_array($type, explode(',', $p['types']))) # Valid type?
$result = it::exec("convert 2>&1 -flatten -quality 75 {-opts} {in} {type}:{out}", $p) === "";
return $result;