mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure withMetadata skips default profile for RGB16 #3773
This commit is contained in:
parent
44a0ee3fd3
commit
95635683ac
@ -109,8 +109,8 @@ await sharp(pixelArray, { raw: { width, height, channels } })
|
|||||||
|
|
||||||
## withMetadata
|
## withMetadata
|
||||||
Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
|
Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
|
||||||
This will also convert to and add a web-friendly sRGB ICC profile unless a custom
|
This will also convert to and add a web-friendly sRGB ICC profile if appropriate,
|
||||||
output profile is provided.
|
unless a custom output profile is provided.
|
||||||
|
|
||||||
The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
|
The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
|
||||||
sRGB colour space and strip all metadata, including the removal of any ICC profile.
|
sRGB colour space and strip all metadata, including the removal of any ICC profile.
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
Requires libvips v8.14.4
|
Requires libvips v8.14.4
|
||||||
|
|
||||||
|
### v0.32.6 - TBD
|
||||||
|
|
||||||
|
* Ensure `withMetadata` does not add default sRGB profile to RGB16 (regression in 0.32.5).
|
||||||
|
[#3773](https://github.com/lovell/sharp/issues/3773)
|
||||||
|
|
||||||
### v0.32.5 - 15th August 2023
|
### v0.32.5 - 15th August 2023
|
||||||
|
|
||||||
* Upgrade to libvips v8.14.4 for upstream bug fixes.
|
* Upgrade to libvips v8.14.4 for upstream bug fixes.
|
||||||
|
File diff suppressed because one or more lines are too long
@ -162,8 +162,8 @@ function toBuffer (options, callback) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
|
* Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
|
||||||
* This will also convert to and add a web-friendly sRGB ICC profile unless a custom
|
* This will also convert to and add a web-friendly sRGB ICC profile if appropriate,
|
||||||
* output profile is provided.
|
* unless a custom output profile is provided.
|
||||||
*
|
*
|
||||||
* The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
|
* The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
|
||||||
* sRGB colour space and strip all metadata, including the removal of any ICC profile.
|
* sRGB colour space and strip all metadata, including the removal of any ICC profile.
|
||||||
|
@ -789,12 +789,14 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
|
|
||||||
// Apply output ICC profile
|
// Apply output ICC profile
|
||||||
if (baton->withMetadata) {
|
if (baton->withMetadata) {
|
||||||
image = image.icc_transform(
|
if (image.interpretation() == VIPS_INTERPRETATION_sRGB || !baton->withMetadataIcc.empty()) {
|
||||||
baton->withMetadataIcc.empty() ? "srgb" : const_cast<char*>(baton->withMetadataIcc.data()),
|
image = image.icc_transform(
|
||||||
VImage::option()
|
baton->withMetadataIcc.empty() ? "srgb" : const_cast<char*>(baton->withMetadataIcc.data()),
|
||||||
->set("input_profile", processingProfile)
|
VImage::option()
|
||||||
->set("embedded", TRUE)
|
->set("input_profile", processingProfile)
|
||||||
->set("intent", VIPS_INTENT_PERCEPTUAL));
|
->set("embedded", TRUE)
|
||||||
|
->set("intent", VIPS_INTENT_PERCEPTUAL));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Override EXIF Orientation tag
|
// Override EXIF Orientation tag
|
||||||
if (baton->withMetadata && baton->withMetadataOrientation != -1) {
|
if (baton->withMetadata && baton->withMetadataOrientation != -1) {
|
||||||
|
@ -794,6 +794,17 @@ describe('Image metadata', function () {
|
|||||||
assert.strictEqual(intent, 'Perceptual');
|
assert.strictEqual(intent, 'Perceptual');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('withMetadata does not add default sRGB profile to RGB16', async () => {
|
||||||
|
const data = await sharp(fixtures.inputJpg)
|
||||||
|
.resize(32, 24)
|
||||||
|
.toColorspace('rgb16')
|
||||||
|
.withMetadata()
|
||||||
|
.toBuffer();
|
||||||
|
|
||||||
|
const metadata = await sharp(data).metadata();
|
||||||
|
assert.strictEqual(undefined, metadata.icc);
|
||||||
|
});
|
||||||
|
|
||||||
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