Problem with resize

See all posts Reply

Problem with resize new!
by Marco A. Braghim, 6 years ago
Hello. I just cant resize any image with the upload.

public function uploadCover($file, $where, $forceX, $forceY) {
  $result = new \stdClass();
  $result->filename = "";
  $result->pathAndFilename = "";
  $result->fileExt = "";

  $upload = new \upload($file, 'pt_BR');
  if ($upload->uploaded) {
    // Formatos Aceitos (Extensoes)
    if (in_array($upload->file_src_name_ext, array('jpeg', 'jpg', 'pdf', 'png', 'gif', 'svg'))) {

      // Formatos Aceitos (Mimetypes)
      $upload->allowed = array(
        'image/jpg',
        'image/pjpeg', // JPG no IE7 e IE8
        'image/jpeg', // JPG no Chrome, Safari, Opera e Firefox
        'image/png',
        'image/gif',
        'application/x-zip-compressed',
        'application/pdf', // PDF p/ IE8 e Mozilla e Chrome e Safari e Opera
        'application/download',
        'application/applefile'
      );

      $upload->file_auto_rename = false;
      $upload->file_overwrite = true;
      $upload->image_convert = 'png';
      $upload->image_resize = true;
      $upload->image_ratio_y = true;
      $upload->image_x = $forceX;
      $upload->image_y = $forceY;

      $upload->process($where);

      // Upload deu tudo certo?
      if ($upload->processed) {

        // Define resultado
        $result->fileExt = $upload->file_src_name_ext;
        $result->filename = $upload->file_dst_name;
        $result->pathAndFilename = $where . $upload->file_dst_name;

        // Permissao total no arquivo
        @chmod($result->pathAndFilename, 0777);

        $upload->clean();
      } else {
        throw new Exception($upload->error);
      }
    } else {
      throw new Exception("Extenssão inválida");
    }
  } else {
    throw new Exception($upload->error);
  }
  return $result;
}


The result of log is:

system information
- class version : 0.35dev
- operating system : Linux
- PHP version : 7.2.12-1+0~20181112102304.11+stretch~1.gbp55f215
- GD version : GD not present
- supported image types : none
- open_basedir : no restriction
- upload_max_filesize : 64M (67108864 bytes)
- language : pt_BR
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
MAGIC path will not be used
MIME type detected as image/png; charset=binary by Fileinfo PECL extension
- MIME validated as image/png
source variables
- You can use all these before calling process()
file_src_name : alias ls=rm -rf.png
file_src_name_body : alias ls=rm -rf
file_src_name_ext : png
file_src_pathname : /tmp/phpXNdcMi
file_src_mime : image/png
file_src_size : 1072774 (max= 67108864)
file_src_error : 0
process file to /var/www/tooba/assets/images/lojas/thizer/
- file size OK
- file mime OK : image/png
- file name safe format
- destination variables
file_dst_path : /var/www/tooba/assets/images/lojas/thizer/
file_dst_name_body : alias-ls-rm-rf
file_dst_name_ext : png
- no auto_rename if same filename exists
- destination file details
file_dst_name : alias-ls-rm-rf.png
file_dst_pathname : /var/www/tooba/assets/images/lojas/thizer/alias-ls-rm-rf.png
- no overwrite checking
- auto-rotate applies only to JPEG images
- no image processing wanted
- process OK
cleanup
- delete temp file /tmp/phpXNdcMi
Reply
Re: Problem with resize new!
by colin, 6 years ago
You cannot use image_y with image_ratio_yReply
Re: Problem with resize new!
by Marco A. Braghim, 6 years ago
Sorry, I forget to remove that before send it to you. That's right, I even try as follow, and whatever way you can imagine too kkkk

$upload->file_auto_rename = false;
$upload->file_overwrite = true;
$upload->image_convert = 'png';
$upload->image_resize = true;
$upload->image_ratio_y = true;
$upload->image_x = 1280;

It doesnt converting the image to png too =/

It's just not working, and I'll check if olders versions are not working too.Reply
Re: Problem with resize new!
by colin, 6 years ago
I see. But it seems that the image is not processed because GD is not present on your system:
- GD version : GD not presentReply
Re: Problem with resize new!
by Marco A. Braghim, 6 years ago
Yeah! That really solved the problem!

$ sudo aptitude install php7.2-gd
$ sudo phpenmod gd
$ sudo service apache2 restart

Thank you very much dude, you and your upload class are awesome! =DReply