summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/graphics.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers/graphics.php')
-rw-r--r--modules/gallery/helpers/graphics.php38
1 files changed, 33 insertions, 5 deletions
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 04501132..3548faa1 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -176,17 +176,25 @@ class graphics_Core {
}
if (!empty($ops["thumb"])) {
+ if (file_exists($item->thumb_path())) {
+ $item->thumb_dirty = 0;
+ } else {
+ copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path());
+ }
$dims = getimagesize($item->thumb_path());
$item->thumb_width = $dims[0];
$item->thumb_height = $dims[1];
- $item->thumb_dirty = 0;
}
if (!empty($ops["resize"])) {
+ if (file_exists($item->resize_path())) {
+ $item->resize_dirty = 0;
+ } else {
+ copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path());
+ }
$dims = getimagesize($item->resize_path());
$item->resize_width = $dims[0];
$item->resize_height = $dims[1];
- $item->resize_dirty = 0;
}
$item->save();
} catch (Exception $e) {
@@ -316,10 +324,10 @@ class graphics_Core {
// ImageMagick & GraphicsMagick
$magick_kits = array(
"imagemagick" => array(
- "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v",
+ "name" => "ImageMagick", "binary" => "convert", "version_arg" => "-v",
"version_regex" => "/Version: \S+ (\S+)/"),
"graphicsmagick" => array(
- "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version",
+ "name" => "GraphicsMagick", "binary" => "gm", "version_arg" => "version",
"version_regex" => "/\S+ (\S+)/"));
// Loop through the kits
foreach ($magick_kits as $index => $settings) {
@@ -328,7 +336,8 @@ class graphics_Core {
$toolkits->$index->name = $settings["name"];
if ($path) {
if (@is_file($path) &&
- preg_match($settings["version_regex"], shell_exec($settings["version"]), $matches)) {
+ preg_match(
+ $settings["version_regex"], shell_exec($path . " " . $settings["version_arg"]), $matches)) {
$version = $matches[1];
$toolkits->$index->installed = true;
@@ -423,4 +432,23 @@ class graphics_Core {
return true;
}
+
+ /**
+ * Return the max file size that this graphics toolkit can handle.
+ */
+ static function max_filesize() {
+ if (module::get_var("gallery", "graphics_toolkit") == "gd") {
+ $memory_limit = trim(ini_get("memory_limit"));
+ $memory_limit_bytes = num::convert_to_bytes($memory_limit);
+
+ // GD expands images in memory and uses 4 bytes of RAM for every byte
+ // in the file.
+ $max_filesize = $memory_limit_bytes / 4;
+ $max_filesize_human_readable = num::convert_to_human_readable($max_filesize);
+ return array($max_filesize, $max_filesize_human_readable);
+ }
+
+ // Some arbitrarily large size
+ return array(1000000000, "1G");
+ }
}