diff options
author | Brion Vibber <brion@pobox.com> | 2010-07-12 14:21:57 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-07-12 14:21:57 -0700 |
commit | cd29d3d646379aa9a1352035973c8e379cc7f42b (patch) | |
tree | e064c5292c546e6df8eaad9609a56150f69c62c3 /lib/imagefile.php | |
parent | bd8506eee883ecd424fdf3d7e545c10c754df6ff (diff) | |
parent | 1b3b7f9a422f6b703ec36d43e2283f91a9835f3b (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib/imagefile.php')
-rw-r--r-- | lib/imagefile.php | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/imagefile.php b/lib/imagefile.php index 7b0479455..e47287741 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -60,6 +60,19 @@ class ImageFile $this->filepath = $filepath; $info = @getimagesize($this->filepath); + + if (!( + ($info[2] == IMAGETYPE_GIF && function_exists('imagecreatefromgif')) || + ($info[2] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg')) || + $info[2] == IMAGETYPE_BMP || + ($info[2] == IMAGETYPE_WBMP && function_exists('imagecreatefromwbmp')) || + ($info[2] == IMAGETYPE_XBM && function_exists('imagecreatefromxbm')) || + ($info[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')))) { + + throw new Exception(_('Unsupported image file format.')); + return; + } + $this->type = ($info) ? $info[2]:$type; $this->width = ($info) ? $info[0]:$width; $this->height = ($info) ? $info[1]:$height; @@ -97,19 +110,6 @@ class ImageFile return; } - if ($info[2] !== IMAGETYPE_GIF && - $info[2] !== IMAGETYPE_JPEG && - $info[2] !== IMAGETYPE_BMP && - $info[2] !== IMAGETYPE_WBMP && - $info[2] !== IMAGETYPE_XBM && - $info[2] !== IMAGETYPE_XPM && - $info[2] !== IMAGETYPE_PNG) { - - @unlink($_FILES[$param]['tmp_name']); - throw new Exception(_('Unsupported image file format.')); - return; - } - return new ImageFile(null, $_FILES[$param]['tmp_name']); } @@ -159,9 +159,6 @@ class ImageFile case IMAGETYPE_XBM: $image_src = imagecreatefromxbm($this->filepath); break; - case IMAGETYPE_XPM: - $image_src = imagecreatefromxpm($this->filepath); - break; default: throw new Exception(_('Unknown file type')); return; @@ -204,10 +201,6 @@ class ImageFile //we don't want to save XBM... it's a rare format that we can't guarantee clients will support //save png instead $this->type = IMAGETYPE_PNG; - } else if($this->type == IMAGETYPE_XPM) { - //we don't want to save XPM... it's a rare format that we can't guarantee clients will support - //save png instead - $this->type = IMAGETYPE_PNG; } $outname = Avatar::filename($this->id, |