diff options
author | Christian Schneider | 2009-06-09 14:25:58 +0000 |
---|---|---|
committer | Christian Schneider | 2009-06-09 14:25:58 +0000 |
commit | 0a7295530982faa7fe01a3650e29731d03ac8162 (patch) | |
tree | 17b1b47ba7e52dd522db96b885ebbe14b8fb8696 /it.class | |
parent | 0de207a9726a2b8390dabb12096c8d21b4ee09ca (diff) | |
download | itools-0a7295530982faa7fe01a3650e29731d03ac8162.tar.gz itools-0a7295530982faa7fe01a3650e29731d03ac8162.tar.bz2 itools-0a7295530982faa7fe01a3650e29731d03ac8162.zip |
Support SVG files as input to it::imageconvert
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -473,7 +473,7 @@ 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" + * @param $p['types'] Comma separated list of accepted input types, default "gif,jpg,png,bmp,tif,jp2,svg" * @return Success of convert as true/false */ function imageconvert($p) @@ -481,14 +481,19 @@ function imageconvert($p) $result = false; $imagetype = @exif_imagetype($p['in']); - if (!function_exists("image_type_to_extension") || !($type = it::replace(array("jpeg" => "jpg", "tiff" => "tif"), image_type_to_extension($imagetype, false)))) + if (!$imagetype && get_class(it_xml::create(@fopen($p['in'], "r"), array('prefix' => "_imageconvert_"))) == "_imageconvert_svg") + { + # 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]; } - $p += array('type' => $type, 'types' => "gif,jpg,png,bmp,tif,jp2"); + $p += array('type' => $type, 'types' => "gif,jpg,png,bmp,tif,jp2,svg"); if (it::match(",$type,", ",{$p['types']},")) # Valid type? $result = it::exec("convert 2>&1 -flatten -quality 75 {-opts} {in} {type}:{out}", array('-opts' => array('-thumbnail' => $p['size'])), $p) === ""; |