mirror of
https://github.com/Intervention/image.git
synced 2025-08-16 19:04:00 +02:00
Rename method
Image::getFrame() to Image::frame()
This commit is contained in:
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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');
|
||||
|
@@ -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)
|
||||
);
|
||||
|
@@ -47,7 +47,7 @@ class ImageFactory implements FactoryInterface
|
||||
{
|
||||
$this->frames->push(
|
||||
$this->handleInput($source)
|
||||
->getFrame()
|
||||
->frame()
|
||||
->setDelay($delay)
|
||||
);
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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()
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user