}
$mini_dest = getthumbsdir () . "/mini_" . basename_safe ($dest);
- try {
- $thumbnail_ok = create_thumbnail ($dest, $mini_dest);
- } catch (Exception $e) {
- $thumbnail_ok = false;
- }
- if (!$thumbnail_ok) {
- if (!copy ($dest, $mini_dest)) {
- server_error ();
- }
+ if (!create_thumbnail_or_copy ($dest, $mini_dest)) {
+ server_error ();
}
-
}
return basename_safe ($dest);
}
$thumbfilename = getthumbsdir () . "/mini_" . $feature->imgpath;
if ((file_exists ($imgfilename)) &&
(!(file_exists ($thumbfilename)))) {
- try {
- create_thumbnail ($imgfilename, $thumbfilename);
- } catch (Exception $e) {
- return false;
- }
+ create_thumbnail_or_copy ($imgfilename, $thumbfilename);
}
}
}
return "$proto://$host$port$path";
}
+function create_thumbnail_or_copy ($filename, $destfile) {
+ try {
+ $thumbnail_ok = create_thumbnail ($filename, $destfile);
+ } catch (Exception $e) {
+ $thumbnail_ok = false;
+ }
+ if (!$thumbnail_ok) {
+ if (!copy ($filename, $destfile)) {
+ return false;
+ }
+ }
+ return true;
+}
+
function create_thumbnail ($filename, $destfile) {
+ if (!function_exists ("imagecreatefromjpeg")
+ || !function_exists ("imagecreatefrompng")) {
+ return false;
+ }
$ext = strtolower (ext_safe ($filename));
if ($ext == "jpg" || $ext == "jpeg") {
$image = imagecreatefromjpeg ($filename);