mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure ICC profiles are removed from PNG output #521
This commit is contained in:
@@ -884,9 +884,12 @@ class PipelineWorker : public AsyncWorker {
|
||||
baton->formatOut = "jpeg";
|
||||
baton->channels = std::min(baton->channels, 3);
|
||||
} else if (baton->formatOut == "png" || (baton->formatOut == "input" && inputImageType == ImageType::PNG)) {
|
||||
// Strip profile
|
||||
if (!baton->withMetadata) {
|
||||
vips_image_remove(image.get_image(), VIPS_META_ICC_NAME);
|
||||
}
|
||||
// Write PNG to buffer
|
||||
VipsArea *area = VIPS_AREA(image.pngsave_buffer(VImage::option()
|
||||
->set("strip", !baton->withMetadata)
|
||||
->set("compression", baton->compressionLevel)
|
||||
->set("interlace", baton->progressive)
|
||||
->set("filter", baton->withoutAdaptiveFiltering ?
|
||||
@@ -961,9 +964,12 @@ class PipelineWorker : public AsyncWorker {
|
||||
baton->formatOut = "jpeg";
|
||||
baton->channels = std::min(baton->channels, 3);
|
||||
} else if (baton->formatOut == "png" || isPng || (matchInput && inputImageType == ImageType::PNG)) {
|
||||
// Strip profile
|
||||
if (!baton->withMetadata) {
|
||||
vips_image_remove(image.get_image(), VIPS_META_ICC_NAME);
|
||||
}
|
||||
// Write PNG to file
|
||||
image.pngsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
||||
->set("strip", !baton->withMetadata)
|
||||
->set("compression", baton->compressionLevel)
|
||||
->set("interlace", baton->progressive)
|
||||
->set("filter", baton->withoutAdaptiveFiltering ?
|
||||
|
||||
Reference in New Issue
Block a user