Reply to webp to webp do not process, jpg to webp or others yes.

webp to webp do not process, jpg to webp or others yes. new!
by Andres Sepcid, 3 years, 8 months ago
Hello friends of the forum.

I have a problem that I hope someone can help me solve.

In order to save space I am working with files converted to webp. Wow, space is saved with this format. The problem I am having is that if I upload a jpg, jpeg, jfif, png file, for example, everything works out fine. But when I upload a webp file the final file is the same original file.

It is as if the class.upload said ... "Since you want a final file in webp and this one that you ask me to process is already a webp then no way, I'll leave you the same and save me work.".

Thanks for the help.

This is my code ...

$image = new Upload($_FILES["imagen"]);
if ($image->uploaded) {
  $image->Process($dir_dest);
  if ($image->processed) {
    $image->file_new_name_body  =   "logo-".md5($_FILES["imagen"]["name"].time());
    $image->image_resize        =   true;
    $image->image_ratio_crop    =   true;
    $image->image_x             =   $medidas[0];
    $image->image_y             =   $medidas[1];
    switch ($img_opt["extension"]) {
      case "webp":
        $image->image_convert       =   "webp";
        $image->webp_quality        =   80;
        break;
      case "jpg":
        $image->image_convert       =   "jpg";
        $image->jpeg_quality        =   80;
        break;
      case "png":
        $image->image_convert       =   "png";
        $image->png_compression     =   5;
        break;
      default:
        $image->image_convert       =   "webp";
        $image->webp_quality        =   80;
        break;
    }
    $image->file_overwrite      =   true;
    $image->process($carpeta);
    $imgupload = $image->file_dst_name;
    $image->clean();
  } else {
    // ERROR DE PROCESAMIENTO
    $sayJson    =   4;
    echo json_encode($sayJson, JSON_FORCE_OBJECT);
    exit();
  }        
}
Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important