Skip to content

Commit

Permalink
Add StripMetaModifierTest::class
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Jan 18, 2025
1 parent 5bfcb52 commit b650658
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Drivers/Imagick/Modifiers/StripMetaModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Intervention\Image\Drivers\Imagick\Modifiers;

use Intervention\Image\Collection;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
use Intervention\Image\Interfaces\SpecializedInterface;
Expand All @@ -22,6 +23,7 @@ public function apply(ImageInterface $image): ImageInterface

// remove meta data
$image->core()->native()->stripImage();
$image->setExif(new Collection());

if ($profiles !== []) {
// re-apply icc profiles
Expand Down
25 changes: 25 additions & 0 deletions tests/Unit/Drivers/Imagick/Modifiers/StripMetaModifierTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Modifiers;

use Intervention\Image\Drivers\Imagick\Modifiers\StripMetaModifier;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Tests\ImagickTestCase;

#[RequiresPhpExtension('imagick')]
#[CoversClass(StripMetaModifier::class)]
final class StripMetaModifierTest extends ImagickTestCase
{
public function testApply(): void
{
$image = $this->readTestImage('exif.jpg');
$this->assertEquals('Oliver Vogel', $image->exif('IFD0.Artist'));
$image->modify(new StripMetaModifier());
$this->assertNull($image->exif('IFD0.Artist'));
$result = $image->toJpeg();
$this->assertEmpty(exif_read_data($result->toFilePointer())['IFD0.Artist'] ?? null);
}
}

0 comments on commit b650658

Please sign in to comment.