Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip parameter to encoders that support exif #1420

Conversation

deluxetom
Copy link
Contributor

work in progress

deluxetom referenced this pull request in Intervention/image-driver-vips Jan 18, 2025
@@ -37,4 +37,17 @@ public function testEncodeProgressive(): void
$this->assertEquals('image/jpeg', $result->mimetype());
$this->assertTrue($this->isProgressiveJpeg($result));
}

public function testEncodeStripExif(): void
Copy link
Member

@olivervogel olivervogel Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GD thing is tricky. There is no real function to delete meta data, but it is possible to create a new GDImage object and copy the data into it. The metadata is not transferred.

However, this does not lead to a consistent result. As the copy action described is used at various points in modifiers in order to achieve different results.

  • src/Drivers/Gd/Modifiers/RotateModifier.php:83
  • src/Drivers/Gd/Modifiers/ContainModifier.php:53
  • src/Drivers/Gd/Modifiers/QuantizeColorsModifier.php:45
  • src/Drivers/Gd/Modifiers/BlendTransparencyModifier.php:25
  • src/Drivers/Gd/Modifiers/CropModifier.php:46
  • src/Drivers/Gd/Modifiers/ResizeModifier.php:40
  • src/Drivers/Gd/Modifiers/CoverModifier.php:40

Basically, the metadata is (almost) always lost with GD and Intervention Image, even if this is not desired. :( This is also the reason why I have not yet integrated a “strip” feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata is apparently not taken into account at all with GD.

$data = fopen('php://temp', 'r+');
$img = imagecreatefromjpeg('exif.jpg'); // decode
imagejpeg($img, $data); // encode
$exif = exif_read_data($data); // exif gone

@olivervogel
Copy link
Member

olivervogel commented Jan 18, 2025

I have developed this further here: #1421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants