@@ -189,7 +189,7 @@ public function setQuality(int $quality) : static
189189 #[ArrayShape(['horizontal ' => 'int ' , 'vertical ' => 'int ' ])]
190190 public function getResolution () : array
191191 {
192- $ resolution = \imageresolution ($ this ->instance );
192+ $ resolution = \imageresolution ($ this ->getInstance () );
193193 if ($ resolution === false ) {
194194 throw new RuntimeException ('Image could not to get resolution ' );
195195 }
@@ -212,7 +212,7 @@ public function getResolution() : array
212212 */
213213 public function setResolution (int $ horizontal = 96 , int $ vertical = 96 ) : static
214214 {
215- $ set = \imageresolution ($ this ->instance , $ horizontal , $ vertical );
215+ $ set = \imageresolution ($ this ->getInstance () , $ horizontal , $ vertical );
216216 if ($ set === false ) {
217217 throw new RuntimeException ('Image could not to set resolution ' );
218218 }
@@ -227,7 +227,7 @@ public function setResolution(int $horizontal = 96, int $vertical = 96) : static
227227 #[Pure]
228228 public function getHeight () : int
229229 {
230- return \imagesy ($ this ->instance );
230+ return \imagesy ($ this ->getInstance () );
231231 }
232232
233233 /**
@@ -238,7 +238,7 @@ public function getHeight() : int
238238 #[Pure]
239239 public function getWidth () : int
240240 {
241- return \imagesx ($ this ->instance );
241+ return \imagesx ($ this ->getInstance () );
242242 }
243243
244244 /**
@@ -300,10 +300,10 @@ public function isType(int $type) : bool
300300 public function create (int | string $ type , string $ filename ) : Image
301301 {
302302 $ created = match ($ type ) {
303- \IMAGETYPE_PNG , 'png ' => \imagepng ($ this ->instance , $ filename ),
304- \IMAGETYPE_JPEG , 'jpeg ' => \imagejpeg ($ this ->instance , $ filename ),
305- \IMAGETYPE_GIF , 'gif ' => \imagegif ($ this ->instance , $ filename ),
306- \IMAGETYPE_AVIF , 'avif ' => \imageavif ($ this ->instance , $ filename ),
303+ \IMAGETYPE_PNG , 'png ' => \imagepng ($ this ->getInstance () , $ filename ),
304+ \IMAGETYPE_JPEG , 'jpeg ' => \imagejpeg ($ this ->getInstance () , $ filename ),
305+ \IMAGETYPE_GIF , 'gif ' => \imagegif ($ this ->getInstance () , $ filename ),
306+ \IMAGETYPE_AVIF , 'avif ' => \imageavif ($ this ->getInstance () , $ filename ),
307307 default => false ,
308308 };
309309 if ($ created === false ) {
@@ -323,10 +323,10 @@ public function save(?string $filename = null) : bool
323323 {
324324 $ filename ??= $ this ->filename ;
325325 return match ($ this ->getType ()) {
326- \IMAGETYPE_PNG => \imagepng ($ this ->instance , $ filename , $ this ->getQuality ()),
327- \IMAGETYPE_JPEG => \imagejpeg ($ this ->instance , $ filename , $ this ->getQuality ()),
328- \IMAGETYPE_GIF => \imagegif ($ this ->instance , $ filename ),
329- \IMAGETYPE_AVIF => \imageavif ($ this ->instance , $ filename , $ this ->getQuality ()),
326+ \IMAGETYPE_PNG => \imagepng ($ this ->getInstance () , $ filename , $ this ->getQuality ()),
327+ \IMAGETYPE_JPEG => \imagejpeg ($ this ->getInstance () , $ filename , $ this ->getQuality ()),
328+ \IMAGETYPE_GIF => \imagegif ($ this ->getInstance () , $ filename ),
329+ \IMAGETYPE_AVIF => \imageavif ($ this ->getInstance () , $ filename , $ this ->getQuality ()),
330330 default => false ,
331331 };
332332 }
@@ -339,13 +339,13 @@ public function save(?string $filename = null) : bool
339339 public function send () : bool
340340 {
341341 if ($ this ->hasAlpha ()) {
342- \imagesavealpha ($ this ->instance , true );
342+ \imagesavealpha ($ this ->getInstance () , true );
343343 }
344344 return match ($ this ->getType ()) {
345- \IMAGETYPE_PNG => \imagepng ($ this ->instance , null , $ this ->getQuality ()),
346- \IMAGETYPE_JPEG => \imagejpeg ($ this ->instance , null , $ this ->getQuality ()),
347- \IMAGETYPE_GIF => \imagegif ($ this ->instance ),
348- \IMAGETYPE_AVIF => \imageavif ($ this ->instance , null , $ this ->getQuality ()),
345+ \IMAGETYPE_PNG => \imagepng ($ this ->getInstance () , null , $ this ->getQuality ()),
346+ \IMAGETYPE_JPEG => \imagejpeg ($ this ->getInstance () , null , $ this ->getQuality ()),
347+ \IMAGETYPE_GIF => \imagegif ($ this ->getInstance () ),
348+ \IMAGETYPE_AVIF => \imageavif ($ this ->getInstance () , null , $ this ->getQuality ()),
349349 default => false ,
350350 };
351351 }
@@ -382,7 +382,7 @@ public function render() : string
382382 */
383383 public function crop (int $ width , int $ height , int $ marginLeft = 0 , int $ marginTop = 0 ) : static
384384 {
385- $ crop = \imagecrop ($ this ->instance , [
385+ $ crop = \imagecrop ($ this ->getInstance () , [
386386 'x ' => $ marginLeft ,
387387 'y ' => $ marginTop ,
388388 'width ' => $ width ,
@@ -413,7 +413,7 @@ public function flip(string $direction = 'horizontal') : static
413413 'b ' , 'both ' => \IMG_FLIP_BOTH ,
414414 default => throw new InvalidArgumentException ('Invalid image flip direction: ' . $ direction ),
415415 };
416- $ flip = \imageflip ($ this ->instance , $ direction );
416+ $ flip = \imageflip ($ this ->getInstance () , $ direction );
417417 if ($ flip === false ) {
418418 throw new RuntimeException ('Image could not to flip ' );
419419 }
@@ -434,7 +434,7 @@ public function flip(string $direction = 'horizontal') : static
434434 */
435435 public function filter (int $ type , int ...$ arguments ) : static
436436 {
437- $ filtered = \imagefilter ($ this ->instance , $ type , ...$ arguments );
437+ $ filtered = \imagefilter ($ this ->getInstance () , $ type , ...$ arguments );
438438 if ($ filtered === false ) {
439439 throw new RuntimeException ('Image could not apply the filter ' );
440440 }
@@ -457,7 +457,7 @@ public function filter(int $type, int ...$arguments) : static
457457 */
458458 public function flatten (int $ red = 255 , int $ green = 255 , int $ blue = 255 ) : static
459459 {
460- \imagesavealpha ($ this ->instance , false );
460+ \imagesavealpha ($ this ->getInstance () , false );
461461 $ image = \imagecreatetruecolor ($ this ->getWidth (), $ this ->getHeight ());
462462 if ($ image === false ) {
463463 throw new RuntimeException ('Could not create a true color image ' );
@@ -476,7 +476,7 @@ public function flatten(int $red = 255, int $green = 255, int $blue = 255) : sta
476476 );
477477 $ copied = \imagecopy (
478478 $ image ,
479- $ this ->instance ,
479+ $ this ->getInstance () ,
480480 0 ,
481481 0 ,
482482 0 ,
@@ -506,25 +506,25 @@ public function opacity(int $opacity = 100) : static
506506 );
507507 }
508508 if ($ opacity === 100 ) {
509- \imagealphablending ($ this ->instance , true );
509+ \imagealphablending ($ this ->getInstance () , true );
510510 return $ this ;
511511 }
512512 $ opacity = (int ) \round (\abs (($ opacity * 127 / 100 ) - 127 ));
513- \imagelayereffect ($ this ->instance , \IMG_EFFECT_OVERLAY );
514- $ color = \imagecolorallocatealpha ($ this ->instance , 127 , 127 , 127 , $ opacity );
513+ \imagelayereffect ($ this ->getInstance () , \IMG_EFFECT_OVERLAY );
514+ $ color = \imagecolorallocatealpha ($ this ->getInstance () , 127 , 127 , 127 , $ opacity );
515515 if ($ color === false ) {
516516 throw new RuntimeException ('Image could not allocate a color ' );
517517 }
518518 \imagefilledrectangle (
519- $ this ->instance ,
519+ $ this ->getInstance () ,
520520 0 ,
521521 0 ,
522522 $ this ->getWidth (),
523523 $ this ->getHeight (),
524524 $ color
525525 );
526- \imagesavealpha ($ this ->instance , true );
527- \imagealphablending ($ this ->instance , false );
526+ \imagesavealpha ($ this ->getInstance () , true );
527+ \imagealphablending ($ this ->getInstance () , false );
528528 return $ this ;
529529 }
530530
@@ -543,7 +543,7 @@ public function rotate(float $angle) : static
543543 if ($ background === false ) {
544544 throw new RuntimeException ('Image could not allocate a color ' );
545545 }
546- $ rotate = \imagerotate ($ this ->instance , -1 * $ angle , $ background );
546+ $ rotate = \imagerotate ($ this ->getInstance () , -1 * $ angle , $ background );
547547 if ($ rotate === false ) {
548548 throw new RuntimeException ('Image could not to rotate ' );
549549 }
@@ -554,11 +554,11 @@ public function rotate(float $angle) : static
554554 protected function allocateBackground () : false | int
555555 {
556556 if ($ this ->hasAlpha ()) {
557- \imagealphablending ($ this ->instance , false );
558- \imagesavealpha ($ this ->instance , true );
559- return \imagecolorallocatealpha ($ this ->instance , 0 , 0 , 0 , 127 );
557+ \imagealphablending ($ this ->getInstance () , false );
558+ \imagesavealpha ($ this ->getInstance () , true );
559+ return \imagecolorallocatealpha ($ this ->getInstance () , 0 , 0 , 0 , 127 );
560560 }
561- return \imagecolorallocate ($ this ->instance , 255 , 255 , 255 );
561+ return \imagecolorallocate ($ this ->getInstance () , 255 , 255 , 255 );
562562 }
563563
564564 public function hasAlpha () : bool
@@ -587,7 +587,7 @@ public function hasAlpha() : bool
587587 */
588588 public function scale (int $ width , int $ height = -1 ) : static
589589 {
590- $ scale = \imagescale ($ this ->instance , $ width , $ height );
590+ $ scale = \imagescale ($ this ->getInstance () , $ width , $ height );
591591 if ($ scale === false ) {
592592 throw new RuntimeException ('Image could not to scale ' );
593593 }
@@ -620,7 +620,7 @@ public function watermark(
620620 - (-1 * $ verticalPosition + $ watermark ->getHeight ());
621621 }
622622 $ copied = \imagecopy (
623- $ this ->instance ,
623+ $ this ->getInstance () ,
624624 $ watermark ->getInstance (),
625625 $ horizontalPosition ,
626626 $ verticalPosition ,
0 commit comments