@@ -277,6 +277,22 @@ protected function _flip(string $direction)
277277 return $ this ;
278278 }
279279
280+ /**
281+ * Changes the image type.
282+ *
283+ * Validates that the target format is supported before applying the change.
284+ *
285+ * @throws ImageException
286+ */
287+ public function convert (int $ imageType )
288+ {
289+ parent ::convert ($ imageType );
290+
291+ $ this ->supportedFormatCheck ();
292+
293+ return $ this ;
294+ }
295+
280296 /**
281297 * Get a driver version
282298 *
@@ -384,20 +400,6 @@ public function save(?string $target = null, int $quality = 90): bool
384400 try {
385401 $ result = $ this ->resource ->writeImage ($ target );
386402
387- if (! $ result || ! file_exists ($ target ) || filesize ($ target ) === 0 ) {
388- $ extension = strtoupper (pathinfo ($ target , PATHINFO_EXTENSION ));
389- $ message = match ($ extension ) {
390- 'GIF ' => lang ('Images.gifNotSupported ' ),
391- 'JPG ' , 'JPEG ' => lang ('Images.jpgNotSupported ' ),
392- 'PNG ' => lang ('Images.pngNotSupported ' ),
393- 'WEBP ' => lang ('Images.webpNotSupported ' ),
394- 'AVIF ' => lang ('Images.avifNotSupported ' ),
395- default => null ,
396- };
397-
398- throw ImageException::forInvalidImageCreate ($ message );
399- }
400-
401403 chmod ($ target , $ this ->filePermissions );
402404
403405 $ this ->resource ->clear ();
0 commit comments