♥Smoky Barnable Posted October 5, 2021 Share Posted October 5, 2021 What's the best way to deal with this error? Fatal error: Uncaught ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range PHP 8 has changed the behavior of the shutup operator - it no longer silences fatal errors. Quote The water in a vessel is sparkling; the water in the sea is dark. The small truth has words which are clear; the great truth has great silence. - Rabindranath Tagore Link to comment Share on other sites More sharing options...
♥Smoky Barnable Posted October 9, 2021 Share Posted October 9, 2021 On 10/5/2021 at 12:52 AM, Smoky Barnable said: What's the best way to deal with this error? Fatal error: Uncaught ValueError: imagecolorsforindex(): Argument #2 ($color) is out of range PHP 8 has changed the behavior of the shutup operator - it no longer silences fatal errors. For those of you who would like to use this addon with PHP 8 the following change cleared this fatal error. In the image.php file, change: $trnprt_color = @imagecolorsforindex ( $this->_image, $trnprt_indx ); to: if ($trnprt_indx < imagecolorstotal($this->_image)){ $trnprt_color = imagecolorsforindex ( $this->_image, $trnprt_indx ); } Hotclutch and Demitry 2 Quote The water in a vessel is sparkling; the water in the sea is dark. The small truth has words which are clear; the great truth has great silence. - Rabindranath Tagore Link to comment Share on other sites More sharing options...
Hotclutch Posted October 16, 2021 Share Posted October 16, 2021 On 9/27/2021 at 1:43 AM, Smoky Barnable said: I have this mostly working with PHP8 except for this warning: Deprecated: Required parameter $quality follows optional parameter $save_in in /home/includes/modules/kiss_image_thumbnailer/classes/Image.php on line 137 protected function _output( $save_in = null, $quality, $filters = null ) { switch ($this->_mime_type) { case self::IMAGETYPE_GIF : return imagegif ( $this->_image, $save_in ); break; case self::IMAGETYPE_JPEG : case self::IMAGETYPE_JPG : $quality = is_null ( $quality ) ? 75 : $quality; return imagejpeg ( $this->_image, $save_in, $quality ); break; case self::IMAGETYPE_PNG : $quality = 9; $filters = is_null ( $filters ) ? null : $filters; return imagepng ( $this->_image, $save_in, $quality, $filters ); break; default : trigger_error ( 'Image cannot be created.', E_USER_NOTICE ); break; } // end switch } // end method I see this warning in the "what's new?" box. protected function _output( $quality, $save_in = null, $filters = null ) { switch ($this->_mime_type) { case self::IMAGETYPE_GIF : return imagegif ( $this->_image, $save_in ); break; case self::IMAGETYPE_JPEG : case self::IMAGETYPE_JPG : $quality = is_null ( $quality ) ? 75 : $quality; return imagejpeg ( $this->_image, $quality, $save_in ); break; case self::IMAGETYPE_PNG : $quality = is_null ( $quality ) ? 0 : $quality; $filters = is_null ( $filters ) ? null : $filters; return imagepng ( $this->_image, $quality, $save_in, $filters ); break; default : trigger_error ( 'Image cannot be created.', E_USER_NOTICE ); break; This works for me. Quote Link to comment Share on other sites More sharing options...
Hotclutch Posted October 16, 2021 Share Posted October 16, 2021 I change the order of the parameters: protected function _output( $quality, $save_in = null, $filters = null ) { and return imagejpeg ( $this->_image, $quality, $save_in ); and return imagepng ( $this->_image, $quality, $save_in, $filters ); Smoky Barnable 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.