Fix Codeigniter 4.1.9 Error |
Hi all!
I am using Codeigniter 4.1.9 with php version 8.1 when i used image class to make Text WaterMark, Convert Image; It have some error with GD Library. I was fixed them. Now, I share my solution: 1. Text WaterMark: - User guide code: Code: \Config\Services::image('imagick') - Error message: Code: "Implicit conversion from float 88.89999999999999 to int loses precision" (error convert float to INT). - Reason: In PHP.NET, function imagecolorclosestalpha() - with opacity parameter must be int value. Follow user guide document, opacity pass to here will be float value - Solution: convert opacity to int value (0-127) by ceil() function - parameter. File: system\Images\Handlers\GDHandler.php Line: 464 Add code: PHP Code: $opacity = ceil($opacity); Another function, with xAsis - yAsis i was used ceil() function to convert float to int value. 2. Convert Imageg\Ser User guide code: Code: \Config\Services::image() Note: When I read sample code, I thought parameter for convert function is destination file but it wrong; parameter for convert() function must equal source file extension - with file save you can set new file (ex: *.png) You can get source file extension with function pathinfo(). I hope this topic can help any body. Thanks for reading! - 3.A (04-29-2022, 09:55 PM)pvt Wrote: 2. Convert Imageg\Ser The documentation is no wrong. There is a bug. See https://github.com/codeigniter4/CodeIgni...ssues/5966 The bug was fixed in the develop branch, and will be included in v4.2.0. (04-29-2022, 09:55 PM)pvt Wrote: This bug was also fixed. https://github.com/codeigniter4/CodeIgni...ssues/5941
(04-29-2022, 09:55 PM)pvt Wrote: Hi all! I have also faced same issue. Did you really find solution??
Hi all!
When attempting to use the image class in Codeigniter 4.1.9 with PHP 8.1 to create a Text WaterMark or convert an image, I encountered an error related to the GD Library. I was able to fix them. Note: I misunderstood the sample code and thought the flyingtogether parameter for the convert function was the file to which the converted data would be written. Instead, the parameter for the convert() function must equal the extension of the file from which the data will be converted. The function pathinfo can be used to determine the extension of a source file.(). Please let this topic be of some use to someone. Much appreciation for taking the time to read this! |
Welcome Guest, Not a member yet? Register Sign In |