1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-17 19:26:25 +02:00

Rename method

Image::getFrame() to Image::frame()
This commit is contained in:
Oliver Vogel
2023-10-26 15:53:26 +02:00
parent 5e5d2dfe33
commit 43d37541db
21 changed files with 30 additions and 30 deletions

View File

@@ -17,7 +17,7 @@ class AvifEncoder extends AbstractEncoder implements EncoderInterface
public function encode(ImageInterface $image): EncodedImage
{
$data = $this->getBuffered(function () use ($image) {
imageavif($image->getFrame()->getCore(), null, $this->quality);
imageavif($image->frame()->getCore(), null, $this->quality);
});
return new EncodedImage($data, 'image/avif');

View File

@@ -12,7 +12,7 @@ class BmpEncoder extends AbstractEncoder implements EncoderInterface
public function encode(ImageInterface $image): EncodedImage
{
$data = $this->getBuffered(function () use ($image) {
imagebmp($image->getFrame()->getCore(), null, false);
imagebmp($image->frame()->getCore(), null, false);
});
return new EncodedImage($data, 'image/bmp');

View File

@@ -17,7 +17,7 @@ class GifEncoder extends AbstractEncoder implements EncoderInterface
}
$data = $this->getBuffered(function () use ($image) {
imagegif($image->getFrame()->getCore());
imagegif($image->frame()->getCore());
});
return new EncodedImage($data, 'image/gif');

View File

@@ -17,7 +17,7 @@ class JpegEncoder extends AbstractEncoder implements EncoderInterface
public function encode(ImageInterface $image): EncodedImage
{
$data = $this->getBuffered(function () use ($image) {
imagejpeg($image->getFrame()->getCore(), null, $this->quality);
imagejpeg($image->frame()->getCore(), null, $this->quality);
});
return new EncodedImage($data, 'image/jpeg');

View File

@@ -12,7 +12,7 @@ class PngEncoder extends AbstractEncoder implements EncoderInterface
public function encode(ImageInterface $image): EncodedImage
{
$data = $this->getBuffered(function () use ($image) {
imagepng($image->getFrame()->getCore(), null, -1);
imagepng($image->frame()->getCore(), null, -1);
});
return new EncodedImage($data, 'image/png');

View File

@@ -17,7 +17,7 @@ class WebpEncoder extends AbstractEncoder implements EncoderInterface
public function encode(ImageInterface $image): EncodedImage
{
$data = $this->getBuffered(function () use ($image) {
imagewebp($image->getFrame()->getCore(), null, $this->quality);
imagewebp($image->frame()->getCore(), null, $this->quality);
});
return new EncodedImage($data, 'image/webp');

View File

@@ -52,7 +52,7 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
return $this;
}
public function getFrame(int $position = 0): FrameInterface
public function frame(int $position = 0): FrameInterface
{
if ($frame = $this->frames->get($position)) {
return $frame;
@@ -70,17 +70,17 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
public function width(): int
{
return imagesx($this->getFrame()->getCore());
return imagesx($this->frame()->getCore());
}
public function height(): int
{
return imagesy($this->getFrame()->getCore());
return imagesy($this->frame()->getCore());
}
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
{
if ($frame = $this->getFrame($frame_key)) {
if ($frame = $this->frame($frame_key)) {
return $this->integerToColor(
imagecolorat($frame->getCore(), $x, $y)
);

View File

@@ -47,7 +47,7 @@ class ImageFactory implements FactoryInterface
{
$this->frames->push(
$this->handleInput($source)
->getFrame()
->frame()
->setDelay($delay)
);

View File

@@ -33,7 +33,7 @@ class PlaceModifier implements ModifierInterface
imagealphablending($frame->getCore(), true);
imagecopy(
$frame->getCore(),
$watermark->getFrame()->getCore(),
$watermark->frame()->getCore(),
$position->getX(),
$position->getY(),
0,

View File

@@ -15,7 +15,7 @@ class AvifEncoder extends AbstractEncoder implements EncoderInterface
$format = 'AVIF';
$compression = Imagick::COMPRESSION_ZIP;
$imagick = $image->getFrame()->getCore();
$imagick = $image->frame()->getCore();
$imagick->setFormat($format);
$imagick->setImageFormat($format);
$imagick->setCompression($compression);

View File

@@ -15,7 +15,7 @@ class BmpEncoder extends AbstractEncoder implements EncoderInterface
$format = 'bmp';
$compression = Imagick::COMPRESSION_NO;
$imagick = $image->getFrame()->getCore();
$imagick = $image->frame()->getCore();
$imagick->setFormat($format);
$imagick->setImageFormat($format);
$imagick->setCompression($compression);

View File

@@ -20,7 +20,7 @@ class JpegEncoder extends AbstractEncoder implements EncoderInterface
$format = 'jpeg';
$compression = Imagick::COMPRESSION_JPEG;
$imagick = $image->getFrame()->getCore();
$imagick = $image->frame()->getCore();
$imagick->setImageBackgroundColor('white');
$imagick->setBackgroundColor('white');
$imagick->setFormat($format);

View File

@@ -15,7 +15,7 @@ class PngEncoder extends AbstractEncoder implements EncoderInterface
$format = 'png';
$compression = Imagick::COMPRESSION_ZIP;
$imagick = $image->getFrame()->getCore();
$imagick = $image->frame()->getCore();
$imagick->setFormat($format);
$imagick->setImageFormat($format);
$imagick->setCompression($compression);

View File

@@ -21,7 +21,7 @@ class WebpEncoder extends AbstractEncoder implements EncoderInterface
$format = 'webp';
$compression = Imagick::COMPRESSION_ZIP;
$imagick = $image->getFrame()->getCore();
$imagick = $image->frame()->getCore();
$imagick->setImageBackgroundColor(new ImagickPixel('transparent'));
$imagick = $imagick->mergeImageLayers(Imagick::LAYERMETHOD_MERGE);

View File

@@ -37,7 +37,7 @@ class Image extends AbstractImage implements ImageInterface, Iterator
return $this->imagick;
}
public function getFrame(int $position = 0): FrameInterface
public function frame(int $position = 0): FrameInterface
{
foreach ($this->imagick as $core) {
if ($core->getIteratorIndex() == $position) {
@@ -126,17 +126,17 @@ class Image extends AbstractImage implements ImageInterface, Iterator
public function width(): int
{
return $this->getFrame()->getCore()->getImageWidth();
return $this->frame()->getCore()->getImageWidth();
}
public function height(): int
{
return $this->getFrame()->getCore()->getImageHeight();
return $this->frame()->getCore()->getImageHeight();
}
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
{
if ($frame = $this->getFrame($frame_key)) {
if ($frame = $this->frame($frame_key)) {
return $this->pixelToColor(
$frame->getCore()->getImagePixelColor($x, $y),
$this->getColorspace()

View File

@@ -29,7 +29,7 @@ class PlaceModifier implements ModifierInterface
foreach ($image as $frame) {
$frame->getCore()->compositeImage(
$watermark->getFrame()->getCore(),
$watermark->frame()->getCore(),
Imagick::COMPOSITE_DEFAULT,
$position->getX(),
$position->getY()

View File

@@ -14,7 +14,7 @@ interface ImageInterface extends Traversable, Countable
* @param int $position
* @return FrameInterface
*/
public function getFrame(int $position = 0): FrameInterface;
public function frame(int $position = 0): FrameInterface;
/**
* Add frame to animated image

View File

@@ -56,8 +56,8 @@ class ImageTest extends TestCase
public function testGetFrame(): void
{
$this->assertInstanceOf(Frame::class, $this->image->getFrame());
$this->assertInstanceOf(Frame::class, $this->image->getFrame(1));
$this->assertInstanceOf(Frame::class, $this->image->frame());
$this->assertInstanceOf(Frame::class, $this->image->frame(1));
}
public function testAddFrame(): void

View File

@@ -18,7 +18,7 @@ class DestroyModifierTest extends TestCase
public function testModify(): void
{
$image = $this->createTestImage('trim.png');
$this->assertInstanceOf(GdImage::class, $image->getFrame()->getCore());
$this->assertInstanceOf(GdImage::class, $image->frame()->getCore());
$image->modify(new DestroyModifier());
}
}

View File

@@ -48,10 +48,10 @@ class ImageTest extends TestCase
public function testGetFrame(): void
{
$this->assertInstanceOf(Frame::class, $this->image->getFrame());
$this->assertInstanceOf(Frame::class, $this->image->getFrame(1));
$this->assertInstanceOf(Frame::class, $this->image->frame());
$this->assertInstanceOf(Frame::class, $this->image->frame(1));
$this->expectException(AnimationException::class);
$this->image->getFrame(2);
$this->image->frame(2);
}
public function testAddFrame(): void

View File

@@ -18,7 +18,7 @@ class DestroyModifierTest extends TestCase
public function testModify(): void
{
$image = $this->createTestImage('trim.png');
$this->assertInstanceOf(Imagick::class, $image->getFrame()->getCore());
$this->assertInstanceOf(Imagick::class, $image->frame()->getCore());
$image->modify(new DestroyModifier());
}
}