1
1
<?php
2
2
/*
3
- * jQuery File Upload Plugin PHP Class 6.10 .0
3
+ * jQuery File Upload Plugin PHP Class 6.11 .0
4
4
* https://github.com/blueimp/jQuery-File-Upload
5
5
*
6
6
* Copyright 2010, Sebastian Tschan
@@ -94,9 +94,14 @@ function __construct($options = null, $initialize = true, $error_messages = null
94
94
'min_height ' => 1 ,
95
95
// Set the following option to false to enable resumable uploads:
96
96
'discard_aborted_uploads ' => true ,
97
- // Set to 0 to use the GD image extension to scale and orient images
98
- // instead of imagick, which is used by default if installed:
97
+ // Set to 0 to use the GD library to scale and orient images,
98
+ // set to 1 to use imagick ( if installed, falls back to GD) :
99
99
'image_library ' => 1 ,
100
+ // Define an array of resource limits for imagick:
101
+ 'imagick_resource_limits ' => array (
102
+ //imagick::RESOURCETYPE_MAP => 32,
103
+ //imagick::RESOURCETYPE_MEMORY => 32
104
+ ),
100
105
// Set to false to disable rotating images based on EXIF meta data:
101
106
'orient_image ' => true ,
102
107
'image_versions ' => array (
@@ -479,6 +484,7 @@ protected function gd_get_image_object($file_path, $func, $no_cache = false) {
479
484
}
480
485
481
486
protected function gd_set_image_object ($ file_path , $ image ) {
487
+ $ this ->gd_destroy_image_object ($ file_path );
482
488
$ this ->image_objects [$ file_path ] = $ image ;
483
489
}
484
490
@@ -577,8 +583,6 @@ protected function gd_create_scaled_image($file_name, $version, $options) {
577
583
$ img_height
578
584
) && $ write_func ($ new_img , $ new_file_path , $ image_quality );
579
585
$ this ->gd_set_image_object ($ file_path , $ new_img );
580
- // Free up memory (imagedestroy does not delete files):
581
- imagedestroy ($ src_img );
582
586
return $ success ;
583
587
}
584
588
@@ -659,6 +663,7 @@ protected function gd_orient_image($file_path) {
659
663
defined ('IMG_FLIP_HORIZONTAL ' ) ? IMG_FLIP_HORIZONTAL : 1
660
664
);
661
665
$ new_img = imagerotate ($ tmp_img , 270 , 0 );
666
+ imagedestroy ($ tmp_img );
662
667
break ;
663
668
case 6 :
664
669
$ new_img = imagerotate ($ src_img , 270 , 0 );
@@ -669,6 +674,7 @@ protected function gd_orient_image($file_path) {
669
674
defined ('IMG_FLIP_VERTICAL ' ) ? IMG_FLIP_VERTICAL : 2
670
675
);
671
676
$ new_img = imagerotate ($ tmp_img , 270 , 0 );
677
+ imagedestroy ($ tmp_img );
672
678
break ;
673
679
case 8 :
674
680
$ new_img = imagerotate ($ src_img , 90 , 0 );
@@ -677,16 +683,19 @@ protected function gd_orient_image($file_path) {
677
683
return false ;
678
684
}
679
685
$ this ->gd_set_image_object ($ file_path , $ new_img );
680
- // Free up memory (imagedestroy does not delete files):
681
- @imagedestroy ($ tmp_img );
682
- imagedestroy ($ src_img );
683
686
return imagejpeg ($ new_img , $ file_path );
684
687
}
685
688
686
689
protected function imagick_get_image_object ($ file_path , $ no_cache = false ) {
687
690
if (empty ($ this ->image_objects [$ file_path ]) || $ no_cache ) {
688
691
$ this ->imagick_destroy_image_object ($ file_path );
689
- $ this ->image_objects [$ file_path ] = new Imagick ($ file_path );
692
+ $ image = new Imagick ($ file_path );
693
+ if (!empty ($ this ->options ['imagick_resource_limits ' ])) {
694
+ foreach ($ this ->options ['imagick_resource_limits ' ] as $ type => $ limit ) {
695
+ $ image ->setResourceLimit ($ type , $ limit );
696
+ }
697
+ }
698
+ $ this ->image_objects [$ file_path ] = $ image ;
690
699
}
691
700
return $ this ->image_objects [$ file_path ];
692
701
}
0 commit comments