diff options
-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) === ""; |