ResponsiveFilemanager icon indicating copy to clipboard operation
ResponsiveFilemanager copied to clipboard

Image Damage with option image_max_width OR image_max_height

Open donario313 opened this issue 6 years ago • 6 comments

On Version 9.14.0, If the original image is to be reduced, then two defective images are created on the server. It worked with version 9.13.3

donario313 avatar May 20 '19 07:05 donario313

On Version 9.13.3 there is a same problem, when uploading a second image (larger as 2048px) with the same name.

$config['image_max_width'] = 2048; $config['image_max_height'] = 2048;

donario313 avatar May 20 '19 14:05 donario313

this problem is with php7.1 (php7.0 and 5.6 works properly), in UploadHandler.php $this->onUploadEnd function is run many times because condition if ($totalSize - $uploaded_bytes - $this->options['readfile_chunk_size'] < 0) doesn't work, so I added

if ($totalSize - $uploaded_bytes - $this->options['readfile_chunk_size'] < 0) {
                $targetPath = $this->options['storeFolder'];
                $targetFile =  $targetPath. $res['files'][0]->name;


                if($size == null || $this->get_file_size($targetFile) == $size)
                {
                    $this->onUploadEnd($res);
                }
                else
                {
                    $this->head();
                $this->body(json_encode($res));
                }
                
            }

mustangpl avatar Feb 10 '20 11:02 mustangpl

does not work in portrait mode

jayD avatar Aug 26 '21 10:08 jayD

The fix proposed by @mustangpl is not correct. The correct test for me is :

if(is_file($this->get_upload_path($name))){
-            $uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]);
-            $totalSize = $this->get_file_size($this->get_upload_path($name));
-            if ($totalSize - $uploaded_bytes - $this->options['readfile_chunk_size'] < 0) {
+            $targetFile =  $this->options['storeFolder'] . $res['files'][0]->name;
+            if($this->get_file_size($targetFile) == $size) {
                 $this->onUploadEnd($res);
             }else{
                 $this->head();

answeb avatar Nov 22 '21 11:11 answeb

The fix proposed by @mustangpl is not correct. The correct test for me is :

if(is_file($this->get_upload_path($name))){
-            $uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]);
-            $totalSize = $this->get_file_size($this->get_upload_path($name));
-            if ($totalSize - $uploaded_bytes - $this->options['readfile_chunk_size'] < 0) {
+            $targetFile =  $this->options['storeFolder'] . $res['files'][0]->name;
+            if($this->get_file_size($targetFile) == $size) {
                 $this->onUploadEnd($res);
             }else{
                 $this->head();

ahh @answeb man, you saved me. Thank you

dikahasyim avatar Dec 09 '21 06:12 dikahasyim

The fix proposed by @mustangpl is not correct. The correct test for me is :

if(is_file($this->get_upload_path($name))){
-            $uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]);
-            $totalSize = $this->get_file_size($this->get_upload_path($name));
-            if ($totalSize - $uploaded_bytes - $this->options['readfile_chunk_size'] < 0) {
+            $targetFile =  $this->options['storeFolder'] . $res['files'][0]->name;
+            if($this->get_file_size($targetFile) == $size) {
                 $this->onUploadEnd($res);
             }else{
                 $this->head();

It works only in Landscape. In portrait mode the images are not converted and remain in original size. Anybody have an idea?

jayD avatar Feb 16 '23 14:02 jayD