Welcome Guest, Not a member yet? Register   Sign In
How to convert an image to WEBP mime type in CI?
#1

(This post was last modified: 10-20-2022, 12:47 PM by luckmoshy.)

Hi all! may someone help me with this issue, please!!

PHP Code:
public function createFile()
    {
 
  $file $this->request->getFile('image');

 

 \
Config\Services::image()->withFile($file)
 ->
convert(IMAGETYPE_WEBP)//it does not convert to real WEBP instead jpeg WHY?
 
->fit(300300'center')
 ->
save(FCPATH .'/image/'.$saveFile->store());

            $data=[
 
  'image'=> $saveFile
 
]; 
 
$model->save($data);
 } 
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#2

PHP | imagewebp() Function
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

All other things being equal, WebP compresses the file more effectively than previous formats (png and jpeg), therefore it uses less hosting space and loads pages more quickly when viewed in a browser.

cwebp image.jpg -o image.webp

cwebp -q 100 image1.jpg -o image1.webp

cwebp -q 100 image2.jpg -o image2.webp

ls -lh image1.jpg image1.webp image2.jpg image2.webp

Then The output of the ls command shows that the size of your images 

Use the -lossless option in place of -q to save the entire, original data of photos during compression. The greatest option for preserving the quality of PNG images is this. Modifying the downloaded PNG image
Reply




Theme © iAndrew 2016 - Forum software by © MyBB