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

StripMetaModifier::class #65

Merged
merged 8 commits into from
Jan 18, 2025
Merged

StripMetaModifier::class #65

merged 8 commits into from
Jan 18, 2025

Conversation

deluxetom
Copy link
Collaborator

Going to keep it as draft, I'm going to update the encoders next

@deluxetom deluxetom requested a review from olivervogel January 18, 2025 15:51
@deluxetom
Copy link
Collaborator Author

@olivervogel I'm not sure this is the best way to remove exif, I followed the example:
https://github.com/libvips/php-vips/blob/master/examples/keep.php

@olivervogel
Copy link
Member

@olivervogel I'm not sure this is the best way to remove exif, I followed the example: https://github.com/libvips/php-vips/blob/master/examples/keep.php

Does the strip option in the writeToBuffer() call remove icc as well?

@deluxetom
Copy link
Collaborator Author

@olivervogel I'm not sure this is the best way to remove exif, I followed the example: https://github.com/libvips/php-vips/blob/master/examples/keep.php

Does the strip option in the writeToBuffer() call remove icc as well?

I believe it does strip all metadata (icc, exif, xmp, iptc)

Copy link
Member

@olivervogel olivervogel left a comment

Choose a reason for hiding this comment

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

I think we should ditch the modifier here and use the output options strip and keep for writeToBuffer().

$strip = $this->strip || (is_null($this->strip) && $this->driver()->config()->strip);

$result = $image->core()->native()->writeToBuffer('.avif', [
            'Q' => $this->quality,
            'strip' => $strip,
             'keep' => Vips\ForeignKeep::ICC,
        ]);

Not sure if this works in combination though. Maybe keep means that every meta data is removed except the given value(s).

@deluxetom
Copy link
Collaborator Author

deluxetom commented Jan 18, 2025

@olivervogel I think we can keep both, the modifier and the strip encoder option.
I believe the modifier can be used before other operations and the ICC profile needs to be kept for the encoder (there can be color changes otherwise)

I just pushed the changes for the Jpeg encoder, let me know what you think

@@ -32,6 +32,7 @@ public function encode(ImageInterface $image): EncodedImage
$result = $vipsImage->writeToBuffer('.jpg', [
'Q' => $this->quality,
'interlace' => $this->progressive,
'strip' => $this->strip || (is_null($this->strip) && $this->driver()->config()->strip),
Copy link
Member

Choose a reason for hiding this comment

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

This would remove icc as well. Shouldn't the profile be retained?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think its better to keep the ICC profiles as well, I'll make the changes

@deluxetom deluxetom requested a review from olivervogel January 18, 2025 16:45
@deluxetom deluxetom marked this pull request as ready for review January 18, 2025 16:45
Copy link
Member

@olivervogel olivervogel left a comment

Choose a reason for hiding this comment

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

Very nice.

@olivervogel olivervogel merged commit 28820bc into develop Jan 18, 2025
8 checks passed
@olivervogel olivervogel deleted the feature/strip-modifier branch January 18, 2025 17:41
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