From 5c5540a0c0b9b5b07e95a9d325229b4463feea3e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 10 Jan 2014 12:38:32 +0100 Subject: let GD itself determine what it can read Signed-off-by: Florian Pritz --- application/models/mfile.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/application/models/mfile.php b/application/models/mfile.php index d7e301b1e..92bf9903f 100644 --- a/application/models/mfile.php +++ b/application/models/mfile.php @@ -123,6 +123,11 @@ class Mfile extends CI_Model { $source_path = $this->file($filedata["hash"]); + $source_gdim = imagecreatefromstring(file_get_contents($source_path)); + if ($source_gdim === false) { + show_error("Unsupported image type"); + } + list($source_width, $source_height, $source_type) = getimagesize($source_path); if ($target_type === null) { @@ -132,20 +137,6 @@ class Mfile extends CI_Model { $target_width = $size; $target_height = $size; - switch ($source_type) { - case IMAGETYPE_GIF: - $source_gdim = imagecreatefromgif($source_path); - break; - case IMAGETYPE_JPEG: - $source_gdim = imagecreatefromjpeg($source_path); - break; - case IMAGETYPE_PNG: - $source_gdim = imagecreatefrompng($source_path); - break; - default: - show_error("Unsupported image type"); - } - $source_aspect_ratio = $source_width / $source_height; $desired_aspect_ratio = $target_width / $target_height; -- cgit v1.2.3-24-g4f1b