Skip to content

Commit df1d666

Browse files
committed
Use imagick->pingImage to retrieve the image dimensions.
Delegate to the get_image_size method to determine the image validity.
1 parent fed5eb4 commit df1d666

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

server/php/UploadHandler.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* jQuery File Upload Plugin PHP Class 6.11.1
3+
* jQuery File Upload Plugin PHP Class 6.11.2
44
* https://github.com/blueimp/jQuery-File-Upload
55
*
66
* Copyright 2010, Sebastian Tschan
@@ -813,14 +813,19 @@ protected function imagick_orient_image($file_path) {
813813

814814
protected function get_image_size($file_path) {
815815
if ($this->options['image_library'] && extension_loaded('imagick')) {
816-
$image = $this->imagick_get_image_object($file_path);
817-
return array($image->getImageWidth(), $image->getImageHeight());
816+
$image = new Imagick();
817+
if (@$image->pingImage($file_path)) {
818+
$dimensions = array($image->getImageWidth(), $image->getImageHeight());
819+
$image->destroy();
820+
return $dimensions;
821+
}
822+
return false;
818823
}
819824
if (!function_exists('getimagesize')) {
820825
error_log('Function not found: getimagesize');
821826
return false;
822827
}
823-
return getimagesize($file_path);
828+
return @getimagesize($file_path);
824829
}
825830

826831
protected function create_scaled_image($file_name, $version, $options) {
@@ -850,12 +855,8 @@ protected function is_valid_image_file($file_path) {
850855
if (function_exists('exif_imagetype')) {
851856
return @exif_imagetype($file_path);
852857
}
853-
if (!function_exists('getimagesize')) {
854-
error_log('Function not found: getimagesize');
855-
return false;
856-
}
857-
$image_info = @getimagesize($file_path);
858-
return !empty($image_info[0]);
858+
$image_info = $this->get_image_size($file_path);
859+
return $image_info && $image_info[0] && $image_info[1];
859860
}
860861

861862
protected function handle_image_file($file_path, $file) {

0 commit comments

Comments
 (0)