-
luckmoshy
Do Codeigniter before do you!
-
Posts: 260
Threads: 53
Joined: Nov 2020
Reputation:
7
01-25-2024, 09:40 PM
(This post was last modified: 01-25-2024, 09:45 PM by luckmoshy.)
Hi, Ci I think @ kenjis one day if I am not mistaken promised to solve this issue at the next CI upgrade but till now is not been working why is it forgotten? or is there another way!!!
PHP Code: $this->sizeImage = \Config\Services::image();
PHP Code: //does not work at all if($file->isValid() && ! $file->hasMoved()) { $this->sizeImage->withFile($file) ->convert(IMAGETYPE_WEBP) ->fit(700,450,true,'center') ->save(FCPATH .'/upload/'. $save = $file->getRandomName()); }
but have used my way to generate and is working
like this
PHP Code: //Here is working.... if($file->isValid() && ! $file->hasMoved()) { $this->sizeImage->withFile($file) //->convert(IMAGETYPE_WEBP) ->fit(700,450,true,'center') ->save(FCPATH .'/upload/'. $save = str_ireplace(['.jpg','.png','.jpeg'],'.webp',$file->getRandomName()); }
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
-
kenjis
Administrator
-
Posts: 3,353
Threads: 91
Joined: Oct 2014
Reputation:
209
-
kenjis
Administrator
-
Posts: 3,353
Threads: 91
Joined: Oct 2014
Reputation:
209
-
luckmoshy
Do Codeigniter before do you!
-
Posts: 260
Threads: 53
Joined: Nov 2020
Reputation:
7
01-26-2024, 08:14 PM
(This post was last modified: 01-26-2024, 08:20 PM by luckmoshy.)
(01-25-2024, 10:42 PM)kenjis Wrote: This bug has been fixed in v4.4.4:
https://github.com/codeigniter4/CodeIgniter4/pull/8210
Thank you @ kenjis but I use the latest CI 4.4.4
this is how I use but not yet working
PHP Code: //does not work at all
public function createFile(){ $this->sizeImage = \Config\Services::image();
$file = $this->request->getFile('img');
if($file->isValid() && ! $file->hasMoved()) { $this->sizeImage->withFile($file) ->convert(IMAGETYPE_WEBP) ->fit(700,450,true,'center') ->save(FCPATH .'/upload/'. $save = $file->getRandomName()); }
$Model->save(['db_image'=>$save]); }
The file is saved but not converted to webp
is somewhere I may be wrong or ?? !!!
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
-
kenjis
Administrator
-
Posts: 3,353
Threads: 91
Joined: Oct 2014
Reputation:
209
Are you usng GD ?
If so, remove `@` in the following and check to see if an error shows.
PHP Code: --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -240,7 +240,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.gifNotSupported')); }
- if (! @imagegif($this->resource, $target)) { + if (! imagegif($this->resource, $target)) { throw ImageException::forSaveFailed(); } break; @@ -250,7 +250,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.jpgNotSupported')); }
- if (! @imagejpeg($this->resource, $target, $quality)) { + if (! imagejpeg($this->resource, $target, $quality)) { throw ImageException::forSaveFailed(); } break; @@ -260,7 +260,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.pngNotSupported')); }
- if (! @imagepng($this->resource, $target)) { + if (! imagepng($this->resource, $target)) { throw ImageException::forSaveFailed(); } break; @@ -270,7 +270,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.webpNotSupported')); }
- if (! @imagewebp($this->resource, $target, $quality)) { + if (! imagewebp($this->resource, $target, $quality)) { throw ImageException::forSaveFailed(); } break;
-
luckmoshy
Do Codeigniter before do you!
-
Posts: 260
Threads: 53
Joined: Nov 2020
Reputation:
7
01-27-2024, 11:49 PM
(This post was last modified: 01-27-2024, 11:57 PM by luckmoshy.)
(01-26-2024, 08:49 PM)kenjis Wrote: Are you usng GD ?
If so, remove `@` in the following and check to see if an error shows.
PHP Code: --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -240,7 +240,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.gifNotSupported')); }
- if (! @imagegif($this->resource, $target)) { + if (! imagegif($this->resource, $target)) { throw ImageException::forSaveFailed(); } break; @@ -250,7 +250,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.jpgNotSupported')); }
- if (! @imagejpeg($this->resource, $target, $quality)) { + if (! imagejpeg($this->resource, $target, $quality)) { throw ImageException::forSaveFailed(); } break; @@ -260,7 +260,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.pngNotSupported')); }
- if (! @imagepng($this->resource, $target)) { + if (! imagepng($this->resource, $target)) { throw ImageException::forSaveFailed(); } break; @@ -270,7 +270,7 @@ class GDHandler extends BaseHandler throw ImageException::forInvalidImageCreate(lang('Images.webpNotSupported')); }
- if (! @imagewebp($this->resource, $target, $quality)) { + if (! imagewebp($this->resource, $target, $quality)) { throw ImageException::forSaveFailed(); } break;
Thank you, @ kenjis, for replying. Sorry for the lateness; yes, I tested. No error and yes, i use GD
Have you tried on your side? Is it working fine for me? I am using xamp local host with laragon + latest CI 4+
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
|