summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2007-05-21 15:15:35 +0000
committerChristian Schneider2007-05-21 15:15:35 +0000
commite63f96ffd59a0e64408fe26cf9006cd1dbb990f4 (patch)
tree6b3dc201311f29164c550dc58595a3a49fbee5f8
parente0e58719da3e74cf377746952ff48c2a9cb25b2b (diff)
downloaditools-e63f96ffd59a0e64408fe26cf9006cd1dbb990f4.tar.gz
itools-e63f96ffd59a0e64408fe26cf9006cd1dbb990f4.tar.bz2
itools-e63f96ffd59a0e64408fe26cf9006cd1dbb990f4.zip
Added it::imageconvert() function
-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;
+}
+
}
+
?>