X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=inc%2Futils.php;h=a55e8794296c3ce6c90c4cc22e649b3a8077fb60;hp=12c85c673dfd321a9b1d1a955103aa93f5895d2c;hb=9d328be613bc25ef3f19f751bcf4de59343944c6;hpb=12376baf148afee289fbb53dd16ee2a0841d5290 diff --git a/inc/utils.php b/inc/utils.php index 12c85c6..a55e879 100644 --- a/inc/utils.php +++ b/inc/utils.php @@ -101,7 +101,25 @@ function full_url_from_path ($path) { 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);