mirror of
https://github.com/lovell/sharp.git
synced 2025-07-10 11:00:14 +02:00
Ensure ICC profiles are removed from PNG output #521
This commit is contained in:
parent
9ddc817a09
commit
032bb7e96b
@ -18,6 +18,10 @@ Requires libvips v8.3.1
|
|||||||
[#511](https://github.com/lovell/sharp/pull/511)
|
[#511](https://github.com/lovell/sharp/pull/511)
|
||||||
[@mhirsch](https://github.com/mhirsch)
|
[@mhirsch](https://github.com/mhirsch)
|
||||||
|
|
||||||
|
* Ensure ICC profiles are removed from PNG output unless withMetadata used.
|
||||||
|
[#521](https://github.com/lovell/sharp/issues/521)
|
||||||
|
[@ChrisPinewood](https://github.com/ChrisPinewood)
|
||||||
|
|
||||||
#### v0.15.1 - 12<sup>th</sup> July 2016
|
#### v0.15.1 - 12<sup>th</sup> July 2016
|
||||||
|
|
||||||
* Concat Stream-based input in single operation for ~+3% perf and less GC.
|
* Concat Stream-based input in single operation for ~+3% perf and less GC.
|
||||||
|
@ -884,9 +884,12 @@ class PipelineWorker : public AsyncWorker {
|
|||||||
baton->formatOut = "jpeg";
|
baton->formatOut = "jpeg";
|
||||||
baton->channels = std::min(baton->channels, 3);
|
baton->channels = std::min(baton->channels, 3);
|
||||||
} else if (baton->formatOut == "png" || (baton->formatOut == "input" && inputImageType == ImageType::PNG)) {
|
} 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
|
// Write PNG to buffer
|
||||||
VipsArea *area = VIPS_AREA(image.pngsave_buffer(VImage::option()
|
VipsArea *area = VIPS_AREA(image.pngsave_buffer(VImage::option()
|
||||||
->set("strip", !baton->withMetadata)
|
|
||||||
->set("compression", baton->compressionLevel)
|
->set("compression", baton->compressionLevel)
|
||||||
->set("interlace", baton->progressive)
|
->set("interlace", baton->progressive)
|
||||||
->set("filter", baton->withoutAdaptiveFiltering ?
|
->set("filter", baton->withoutAdaptiveFiltering ?
|
||||||
@ -961,9 +964,12 @@ class PipelineWorker : public AsyncWorker {
|
|||||||
baton->formatOut = "jpeg";
|
baton->formatOut = "jpeg";
|
||||||
baton->channels = std::min(baton->channels, 3);
|
baton->channels = std::min(baton->channels, 3);
|
||||||
} else if (baton->formatOut == "png" || isPng || (matchInput && inputImageType == ImageType::PNG)) {
|
} 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
|
// Write PNG to file
|
||||||
image.pngsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
image.pngsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
||||||
->set("strip", !baton->withMetadata)
|
|
||||||
->set("compression", baton->compressionLevel)
|
->set("compression", baton->compressionLevel)
|
||||||
->set("interlace", baton->progressive)
|
->set("interlace", baton->progressive)
|
||||||
->set("filter", baton->withoutAdaptiveFiltering ?
|
->set("filter", baton->withoutAdaptiveFiltering ?
|
||||||
|
@ -328,6 +328,22 @@ describe('Image metadata', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Remove metadata from PNG output', function(done) {
|
||||||
|
sharp(fixtures.inputJpgWithExif)
|
||||||
|
.png()
|
||||||
|
.toBuffer(function(err, buffer) {
|
||||||
|
if (err) throw err;
|
||||||
|
sharp(buffer).metadata(function(err, metadata) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual(false, metadata.hasProfile);
|
||||||
|
assert.strictEqual('undefined', typeof metadata.orientation);
|
||||||
|
assert.strictEqual('undefined', typeof metadata.exif);
|
||||||
|
assert.strictEqual('undefined', typeof metadata.icc);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('File input with corrupt header fails gracefully', function(done) {
|
it('File input with corrupt header fails gracefully', function(done) {
|
||||||
sharp(fixtures.inputJpgWithCorruptHeader)
|
sharp(fixtures.inputJpgWithCorruptHeader)
|
||||||
.metadata(function(err) {
|
.metadata(function(err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user