lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.36k stars 1.3k forks source link

metadata.comments but no withMetadata({comments:[]}) #4217

Closed KaruroChori closed 2 months ago

KaruroChori commented 2 months ago

Question about an existing feature

What are you trying to achieve?

I would like to remove comments stored in the metadata of a PNG. I can read them from images, but I have not been able to remove them. I have not been able to find a functionality mirroring it.

When you searched for similar issues, what did you find that might be related?

No, not really, as for all the other fields there is parity for what I can tell.
This one specifically is either not implemented or I failed to find it.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

Something like this would be expected to return the buffer of an image with the comments section empty.

const dataWithExif = await sharp(await Bun.file(args.sourceFile).arrayBuffer())
                                        .withMetadata({comments:[]})
                                        .toBuffer();

Any other combination I tried to prevent metadata from being saved still preserved comments.

Please provide sample image(s) that help explain this question

Not sure if github will preserve the metadata, but here is an example with two entries in comments: prompt and worklow: ComfyUI_temp_ghcap_00001_

lovell commented 2 months ago

Please see #3549

KaruroChori commented 2 months ago

Great, thanks for the reference!