verot / class.upload.php

This PHP class uploads files and manipulates images very easily. It is in fact as much as an image processing class than it is an upload class. Compatible with PHP 4, 5, 7 and 8. Supports processing of local files, uploaded files, files sent through XMLHttpRequest.
http://www.verot.net/php_class_upload.htm
GNU General Public License v2.0
853 stars 359 forks source link

Upload going with low quality - Serrated #116

Closed tiagocaus closed 5 years ago

tiagocaus commented 5 years ago

My images are being sent with low quality.

Because?

Look: http://prntscr.com/nrdnad

if (!empty($_FILES['avariaFoto']['name'])) {
  $files = array();
  foreach($_FILES['avariaFoto'] as $k => $l) {
    foreach($l as $i => $v) {
      if (!array_key_exists($i, $files)) $files[$i] = array();
      $files[$i][$k] = $v;
    }
  }
  foreach($files as $file) {
    $handle = new upload($file);
    if ($handle - > uploaded) {
      $handle - > file_new_name_body = date('dmYhis');
      $handle - > image_resize = true;
      $handle - > image_x = 800;
      $handle - > image_ratio_y = true;
      $handle - > jpeg_quality = 85;
      $handle - > image_convert = 'jpg';
      $handle - > file_overwrite = false;
      $handle - > file_auto_rename = true;
      $handle - > mime_check = true;
      $handle - > Process('imagens/');
      $foto = $handle - > file_dst_name;

      if ($handle - > processed) {
        $handle - > clean();
      } else {
        echo '  Erro: '.$handle - > error.
        '';
      }
    }
  }
}
verot commented 5 years ago

As I said, it is not a support forum. Please check the logs produced by the class, you will have more insight regarding the resizing of the files.