Skip to content

Commit

Permalink
strip metadata for webp and avif
Browse files Browse the repository at this point in the history
webp and avif is mainly for browser, it's safe to strip metadata.
  • Loading branch information
liudongmiao committed Aug 19, 2024
1 parent a510db8 commit d5a25df
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vips/foreign.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int set_gifsave_options(VipsOperation *operation, SaveParams *params) {

int set_avifsave_options(VipsOperation *operation, SaveParams *params) {
int ret = vips_object_set(
VIPS_OBJECT(operation), "compression", VIPS_FOREIGN_HEIF_COMPRESSION_AV1,
VIPS_OBJECT(operation), "strip", params->stripMetadata, "compression", VIPS_FOREIGN_HEIF_COMPRESSION_AV1,
"lossless", params->heifLossless, "speed", params->avifSpeed, NULL);

if (!ret && params->quality) {
Expand Down
1 change: 1 addition & 0 deletions vips/foreign.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func vipsSaveAVIFToBuffer(in *C.VipsImage, params AvifExportParams) ([]byte, err
p := C.create_save_params(C.AVIF)
p.inputImage = in
p.outputFormat = C.AVIF
p.stripMetadata = C.int(boolToInt(params.StripMetadata))
p.quality = C.int(params.Quality)
p.heifLossless = C.int(boolToInt(params.Lossless))
p.avifSpeed = C.int(params.Speed)
Expand Down
2 changes: 2 additions & 0 deletions vips/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ func (v *Processor) export(
return image.ExportPng(opts)
case ImageTypeWEBP:
opts := NewWebpExportParams()
opts.StripMetadata = true
if quality > 0 {
opts.Quality = quality
}
Expand All @@ -613,6 +614,7 @@ func (v *Processor) export(
return image.ExportGIF(opts)
case ImageTypeAVIF:
opts := NewAvifExportParams()
opts.StripMetadata = true
if quality > 0 {
opts.Quality = quality
}
Expand Down

0 comments on commit d5a25df

Please sign in to comment.