summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-01-10 12:38:32 +0100
committerFlorian Pritz <bluewind@xinu.at>2014-01-10 12:38:32 +0100
commit5c5540a0c0b9b5b07e95a9d325229b4463feea3e (patch)
tree95ed03e913744c03c56fb093f57a24e4c7241ee9
parent4a92fbad4beb9d27f4bbfa4f9360bddf455e671f (diff)
let GD itself determine what it can read
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/models/mfile.php19
1 files 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;