@@ -718,42 +718,27 @@ public function send(int $type = ImageType::JPEG, ?int $quality = null): void
718718	 */ 
719719	private  function  output (int  $ typeint  $ qualitystring  $ filenull ): void 
720720	{
721- 		switch  ($ type
722- 			case  ImageType::JPEG :
723- 				$ quality$ qualitynull  ? 85  : max (0 , min (100 , $ quality
724- 				$ successimagejpeg ($ this image , $ file$ quality// @ is escalated to exception 
725- 				break ;
726- 
727- 			case  ImageType::PNG :
728- 				$ quality$ qualitynull  ? 9  : max (0 , min (9 , $ quality
729- 				$ successimagepng ($ this image , $ file$ quality// @ is escalated to exception 
730- 				break ;
731- 
732- 			case  ImageType::GIF :
733- 				$ successimagegif ($ this image , $ file// @ is escalated to exception 
734- 				break ;
735- 
736- 			case  ImageType::WEBP :
737- 				$ quality$ qualitynull  ? 80  : max (0 , min (100 , $ quality
738- 				$ successimagewebp ($ this image , $ file$ quality// @ is escalated to exception 
739- 				break ;
740- 
741- 			case  ImageType::AVIF :
742- 				$ quality$ qualitynull  ? 30  : max (0 , min (100 , $ quality
743- 				$ successimageavif ($ this image , $ file$ quality// @ is escalated to exception 
744- 				break ;
745- 
746- 			case  ImageType::BMP :
747- 				$ successimagebmp ($ this image , $ file// @ is escalated to exception 
748- 				break ;
749- 
750- 			default :
751- 				throw  new  Nette \InvalidArgumentException ("Unsupported image type ' $ type'. " );
752- 		}
753- 
754- 		if  (!$ success
755- 			throw  new  ImageException (Helpers::getLastError () ?: 'Unknown error ' );
756- 		}
721+ 		[$ default$ min$ maxmatch  ($ type
722+ 			ImageType::JPEG  => [85 , 0 , 100 ],
723+ 			ImageType::PNG  => [9 , 0 , 9 ],
724+ 			ImageType::GIF  => [null , null , null ],
725+ 			ImageType::WEBP  => [80 , 0 , 100 ],
726+ 			ImageType::AVIF  => [30 , 0 , 100 ],
727+ 			ImageType::BMP  => [null , null , null ],
728+ 			default  => throw  new  Nette \InvalidArgumentException ("Unsupported image type ' $ type'. " ),
729+ 		};
730+ 
731+ 		$ args$ this image , $ file
732+ 		if  ($ defaultnull ) {
733+ 			$ args$ qualitynull  ? $ defaultmax ($ minmin ($ max$ quality
734+ 		}
735+ 
736+ 		Callback::invokeSafe ('image '  . self ::Formats[$ type$ argsfunction  (string  $ messageuse  ($ filevoid  {
737+ 			if  ($ filenull ) {
738+ 				@unlink ($ file
739+ 			}
740+ 			throw  new  ImageException ($ message
741+ 		});
757742	}
758743
759744
0 commit comments