mirror of
https://github.com/Intervention/image.git
synced 2025-09-02 02:12:37 +02:00
Switch EncodedImage::class to temporary stream resource
This commit is contained in:
@@ -19,6 +19,6 @@ final class AvifEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new AvifEncoder(10);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/avif', (string) $result);
|
||||
$this->assertMediaType('image/avif', $result);
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,6 @@ final class BmpEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new BmpEncoder();
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType(['image/bmp', 'image/x-ms-bmp'], (string) $result);
|
||||
$this->assertMediaType(['image/bmp', 'image/x-ms-bmp'], $result);
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ final class GifEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new GifEncoder();
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
$this->assertFalse(
|
||||
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
|
||||
);
|
||||
@@ -31,7 +31,7 @@ final class GifEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new GifEncoder(interlaced: true);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
$this->assertTrue(
|
||||
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
|
||||
);
|
||||
@@ -42,7 +42,7 @@ final class GifEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestAnimation();
|
||||
$encoder = new GifEncoder(interlaced: true);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
$this->assertTrue(
|
||||
Decoder::decode((string) $result)->getFirstFrame()->getImageDescriptor()->isInterlaced()
|
||||
);
|
||||
|
@@ -19,6 +19,6 @@ final class HeicEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new HeicEncoder(75);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/heic', (string) $result);
|
||||
$this->assertMediaType('image/heic', $result);
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,6 @@ final class Jpeg2000EncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new Jpeg2000Encoder(75);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/jp2', (string) $result);
|
||||
$this->assertMediaType('image/jp2', $result);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ final class JpegEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new JpegEncoder(75);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/jpeg', (string) $result);
|
||||
$this->assertMediaType('image/jpeg', $result);
|
||||
}
|
||||
|
||||
public function testEncodeProgressive(): void
|
||||
@@ -30,7 +30,7 @@ final class JpegEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new JpegEncoder(progressive: true);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/jpeg', (string) $result);
|
||||
$this->assertTrue($this->isProgressiveJpeg((string) $result));
|
||||
$this->assertMediaType('image/jpeg', $result);
|
||||
$this->assertTrue($this->isProgressiveJpeg($result));
|
||||
}
|
||||
}
|
||||
|
@@ -24,8 +24,8 @@ final class PngEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new PngEncoder();
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
$this->assertFalse($this->isInterlacedPng((string) $result));
|
||||
$this->assertMediaType('image/png', $result);
|
||||
$this->assertFalse($this->isInterlacedPng($result));
|
||||
}
|
||||
|
||||
public function testEncodeInterlaced(): void
|
||||
@@ -33,8 +33,8 @@ final class PngEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new PngEncoder(interlaced: true);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
$this->assertTrue($this->isInterlacedPng((string) $result));
|
||||
$this->assertMediaType('image/png', $result);
|
||||
$this->assertTrue($this->isInterlacedPng($result));
|
||||
}
|
||||
|
||||
#[DataProvider('indexedDataProvider')]
|
||||
@@ -42,7 +42,7 @@ final class PngEncoderTest extends ImagickTestCase
|
||||
{
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->pngColorType((string) $encoder->encode($image)),
|
||||
$this->pngColorType($encoder->encode($image)),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,6 @@ final class TiffEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new TiffEncoder();
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/tiff', (string) $result);
|
||||
$this->assertMediaType('image/tiff', $result);
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,6 @@ final class WebpEncoderTest extends ImagickTestCase
|
||||
$image = $this->createTestImage(3, 2);
|
||||
$encoder = new WebpEncoder(75);
|
||||
$result = $encoder->encode($image);
|
||||
$this->assertMediaType('image/webp', (string) $result);
|
||||
$this->assertMediaType('image/webp', $result);
|
||||
}
|
||||
}
|
||||
|
@@ -151,40 +151,40 @@ final class ImageTest extends ImagickTestCase
|
||||
{
|
||||
$result = $this->readTestImage('blue.gif')->encode();
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
}
|
||||
|
||||
public function testEncodeByMediaType(): void
|
||||
{
|
||||
$result = $this->readTestImage('blue.gif')->encodeByMediaType();
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
|
||||
$result = $this->readTestImage('blue.gif')->encodeByMediaType('image/png');
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
$this->assertMediaType('image/png', $result);
|
||||
}
|
||||
|
||||
public function testEncodeByExtension(): void
|
||||
{
|
||||
$result = $this->readTestImage('blue.gif')->encodeByExtension();
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
|
||||
$result = $this->readTestImage('blue.gif')->encodeByExtension('png');
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
$this->assertMediaType('image/png', $result);
|
||||
}
|
||||
|
||||
public function testEncodeByPath(): void
|
||||
{
|
||||
$result = $this->readTestImage('blue.gif')->encodeByPath();
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
$this->assertMediaType('image/gif', $result);
|
||||
|
||||
$result = $this->readTestImage('blue.gif')->encodeByPath('foo/bar.png');
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
$this->assertMediaType('image/png', $result);
|
||||
}
|
||||
|
||||
public function testSaveAsFormat(): void
|
||||
@@ -293,51 +293,51 @@ final class ImageTest extends ImagickTestCase
|
||||
|
||||
public function testToJpeg(): void
|
||||
{
|
||||
$this->assertMediaType('image/jpeg', (string) $this->image->toJpeg());
|
||||
$this->assertMediaType('image/jpeg', (string) $this->image->toJpg());
|
||||
$this->assertMediaType('image/jpeg', $this->image->toJpeg());
|
||||
$this->assertMediaType('image/jpeg', $this->image->toJpg());
|
||||
}
|
||||
|
||||
public function testToJpeg2000(): void
|
||||
{
|
||||
$this->assertMediaType('image/jp2', (string) $this->image->toJpeg2000());
|
||||
$this->assertMediaType('image/jp2', (string) $this->image->toJp2());
|
||||
$this->assertMediaType('image/jp2', $this->image->toJpeg2000());
|
||||
$this->assertMediaType('image/jp2', $this->image->toJp2());
|
||||
}
|
||||
|
||||
public function testToPng(): void
|
||||
{
|
||||
$this->assertMediaType('image/png', (string) $this->image->toPng());
|
||||
$this->assertMediaType('image/png', $this->image->toPng());
|
||||
}
|
||||
|
||||
public function testToGif(): void
|
||||
{
|
||||
$this->assertMediaType('image/gif', (string) $this->image->toGif());
|
||||
$this->assertMediaType('image/gif', $this->image->toGif());
|
||||
}
|
||||
|
||||
public function testToWebp(): void
|
||||
{
|
||||
$this->assertMediaType('image/webp', (string) $this->image->toWebp());
|
||||
$this->assertMediaType('image/webp', $this->image->toWebp());
|
||||
}
|
||||
|
||||
public function testToBitmap(): void
|
||||
{
|
||||
$this->assertMediaTypeBitmap((string) $this->image->toBitmap());
|
||||
$this->assertMediaTypeBitmap((string) $this->image->toBmp());
|
||||
$this->assertMediaTypeBitmap($this->image->toBitmap());
|
||||
$this->assertMediaTypeBitmap($this->image->toBmp());
|
||||
}
|
||||
|
||||
public function testToAvif(): void
|
||||
{
|
||||
$this->assertMediaType('image/avif', (string) $this->image->toAvif());
|
||||
$this->assertMediaType('image/avif', $this->image->toAvif());
|
||||
}
|
||||
|
||||
public function testToTiff(): void
|
||||
{
|
||||
$this->assertMediaType('image/tiff', (string) $this->image->toTiff());
|
||||
$this->assertMediaType('image/tiff', (string) $this->image->toTif());
|
||||
$this->assertMediaType('image/tiff', $this->image->toTiff());
|
||||
$this->assertMediaType('image/tiff', $this->image->toTif());
|
||||
}
|
||||
|
||||
public function testToHeic(): void
|
||||
{
|
||||
$this->assertMediaType('image/heic', (string) $this->image->toHeic());
|
||||
$this->assertMediaType('image/heic', $this->image->toHeic());
|
||||
}
|
||||
|
||||
public function testInvert(): void
|
||||
|
Reference in New Issue
Block a user