Skip to content

Commit

Permalink
Merge pull request blueimp#2788 from exussum12/exif_imagetype
Browse files Browse the repository at this point in the history
Use Exif Data to check the image type, Do not rely on extention
  • Loading branch information
blueimp committed Dec 5, 2013
2 parents fb2c280 + 54c055c commit f8692e7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion server/php/UploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,25 @@ protected function gd_create_scaled_image($file_name, $version, $options) {
}
list($file_path, $new_file_path) =
$this->get_scaled_image_file_paths($file_name, $version);
$type = strtolower(substr(strrchr($file_name, '.'), 1));
if (function_exists('exif_imagetype')) {
//use the signature of the file
switch(exif_imagetype($file_path)){
case IMAGETYPE_JPEG:
$type = 'jpg';
break;
case IMAGETYPE_PNG:
$type = 'png';
break;
case IMAGETYPE_GIF:
$type = 'gif';
break;
default:
$type = '';
}
}else {
//use the extention;
$type = strtolower(substr(strrchr($file_name, '.'), 1));
}
switch ($type) {
case 'jpg':
case 'jpeg':
Expand Down

0 comments on commit f8692e7

Please sign in to comment.