Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Use Exif Data to check the image type, Do not rely on extention #2788

Merged
merged 1 commit into from
Dec 5, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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