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

See all posts Reply

webp to webp do not process, jpg to webp or others yes. new!
by Andres Sepcid, 2 years, 11 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
Re: webp to webp do not process, jpg to webp or others yes. new!
by colin, 2 years, 11 months ago
Can you copy here the log produced by the class when processing a webp file?Reply
Re: webp to webp do not process, jpg to webp or others yes. new!
by Andres Sepcid, 2 years, 11 months ago
This is the log after generating the process.

system information
- class version : 0.33dev
- operating system : Linux
- PHP version : 7.3.27
- GD version : 2.1.0
- supported image types : png jpg gif bmp
- open_basedir : /home/:/tmp:/usr/local/lib/:/var/cpanel/php/sessions/ea-php73
- upload_max_filesize : 150M (157286400 bytes)
- language : en_GB
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/webp; charset=binary by Fileinfo PECL extension
- MIME validated as image/webp
source variables
- You can use all these before calling process()
file_src_name : correos.webp
file_src_name_body : correos
file_src_name_ext : webp
file_src_pathname : /tmp/php0K72Dj
file_src_mime : image/webp
file_src_size : 28472 (max= 157286400)
file_src_error : 0
process file to tmp/
- file size OK
- file mime OK : image/webp
- file name safe format
- destination variables
file_dst_path : tmp/
file_dst_name_body : correos
file_dst_name_ext : webp
- checking for auto_rename
- destination file details
file_dst_name : correos.webp
file_dst_pathname : tmp/correos.webp
- correos.webp doesn't exist already
- tmp/ doesn't exist. Attempting creation: success
- no image processing wanted
- process OK
process file to /home/xxxxxx/public_html/xxxxxx/xxxxxx/logos/
- file size OK
- file mime OK : image/webp
- new file name body : logo-e6983bced6a5802bcf2e8a3eba17d5e5
- file name safe format
- destination variables
file_dst_path : /home/xxxxxx/public_html/xxxxxx/xxxxxx/logos/
file_dst_name_body : logo-e6983bced6a5802bcf2e8a3eba17d5e5
file_dst_name_ext : webp
- no auto_rename if same filename exists
- destination file details
file_dst_name : logo-e6983bced6a5802bcf2e8a3eba17d5e5.webp
file_dst_pathname : /home/xxxxxx/public_html/xxxxxx/xxxxxx/logos/logo-e6983bced6a5802bcf2e8a3eba17d5e5.webp
- no overwrite checking
- no image processing wanted
- process OKReply
Re: webp to webp do not process, jpg to webp or others yes. new!
by colin, 2 years, 11 months ago
It seems that you are not using the latest version of the class. Can you get the latest version from GitHub?Reply
Re: webp to webp do not process, jpg to webp or others yes. new!
by Andres Sepcid, 2 years, 11 months ago
Excellent! That was the problem. I just uploaded a webp image and it generated the process according to the parameters indicated in the programming.
Thank you very much for your help.Reply