summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
Diffstat (limited to 'it.class')
-rw-r--r--it.class22
1 files changed, 22 insertions, 0 deletions
diff --git a/it.class b/it.class
index 4e2ce97..761471c 100644
--- a/it.class
+++ b/it.class
@@ -306,5 +306,27 @@ function exec(/* ... */)
return (string)shell_exec($cmd);
}
+/**
+ * Convert an image to a given size and type (ensures input is an image)
+ * @param $p['in'] Input filename (mandatory)
+ * @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"
+ * @return Success of convert as true/false
+ */
+function imageconvert($p)
+{
+ $result = false;
+ $type = it::replace("jpeg" => "jpg", "tiff" => "tif", image_type_to_extension(exif_imagetype($p['in']), false));
+ $p += array('type' => $type, 'types' => "gif,jpg,png,bmp,tif,jp2");
+
+ if (it::match(",$type,", ",{$p['types']},")) # Valid type?
+ $result = it::exec('convert 2>&1 -flatten', '-thumbnail' => $p['size'], $p['in'], $p['type'] . ":" . $p['out']) === "";
+
+ return $result;
+}
+
}
+
?>