From 0a7295530982faa7fe01a3650e29731d03ac8162 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Tue, 9 Jun 2009 14:25:58 +0000 Subject: Support SVG files as input to it::imageconvert --- it.class | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index d8e4098..ebbecbc 100644 --- a/it.class +++ b/it.class @@ -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) === ""; -- cgit v1.2.3