Welcome Guest, Not a member yet? Register   Sign In
Help Image Manipulation Class
#1

How To rename extension that use Convert() method ?

my code below does not automatically rename file extension 

PHP Code:
        
        $img 
$this->request->getFile('image');
        $newimage $img->getRandomName();

        \Config\Services::image()
            ->withFile($newimage)
            ->resize(1360768false'auto')
            ->convert(IMAGETYPE_WEBP)
            ->save(FCPATH '/img/');
        $img->move(WRITEPATH '../public/img/');

        dd($img->getName()); 

My output file name still jpg/png
I need webp extension output filename.
Please help.
Reply
#2

How To Convert JPG, PNG, GIF, And WebP In PHP With Practical Examples
What did you Try? What did you Get? What did you Expect?

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

(This post was last modified: 03-02-2023, 01:04 AM by luckmoshy.)

PHP Code:
$img $this->request->getFile('image');
        $newimage =str_ireplace(['.jpg','.png','jpeg'],'.webp'$img->getRandomName());

        \Config\Services::image()
            ->withFile($newimage)
            ->resize(1360768false'auto')
            ->convert(IMAGETYPE_WEBP)
            ->save(FCPATH '/img/');
        $img->move(WRITEPATH '../public/img/');

        dd($img->getName()); 
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#4
Thumbs Up 

(03-02-2023, 01:02 AM)luckmoshy Wrote:
PHP Code:
$img $this->request->getFile('image');
        $newimage =str_ireplace(['.jpg','.png','jpeg'],'.webp'$img->getRandomName());

        \Config\Services::image()
            ->withFile($newimage)
            ->resize(1360768false'auto')
            ->convert(IMAGETYPE_WEBP)
            ->save(FCPATH '/img/');
        $img->move(WRITEPATH '../public/img/');

        dd($img->getName()); 

thanks sir, it's work .
Reply




Theme © iAndrew 2016 - Forum software by © MyBB