Skip to content

Commit e33796d

Browse files
committed
Merge branch '8.13'
2 parents 2335172 + 982a835 commit e33796d

File tree

6 files changed

+48
-17
lines changed

6 files changed

+48
-17
lines changed

libvips/foreign/spngsave.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ vips_foreign_save_spng_pack( VipsForeignSaveSpng *spng,
270270
VipsPel *q, VipsPel *p, size_t n )
271271
{
272272
int pixel_mask = 8 / spng->bitdepth - 1;
273-
int shift = 8 - spng->bitdepth;
273+
int shift = spng->palette ? 0 : 8 - spng->bitdepth;
274274

275275
VipsPel bits;
276276
size_t x;

libvips/resample/thumbnail.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -859,20 +859,37 @@ vips_thumbnail_build( VipsObject *object )
859859
in = t[7];
860860
}
861861
else if( thumbnail->export_profile ) {
862-
/* We are in one of the resize space (sRGB, scRGB, B_W, GREY16,
863-
* etc.) and we have an export profile. Go to PCS, then export.
862+
/* If there's some kind of import profile, we can transform to
863+
* the output. Otherwise, we are in one of the resize space
864+
* (sRGB, scRGB, B_W, GREY16, etc.) and need to go to PCS,
865+
* then export.
864866
*/
865-
g_info( "exporting with %s",
866-
thumbnail->export_profile );
867-
if( vips_colourspace( in, &t[7],
868-
VIPS_INTERPRETATION_XYZ, NULL ) ||
869-
vips_icc_export( t[7], &t[10],
870-
"output_profile",
871-
thumbnail->export_profile,
867+
if( thumbnail->import_profile ||
868+
vips_image_get_typeof( in, VIPS_META_ICC_NAME ) ) {
869+
g_info( "transforming with supplied profiles" );
870+
if( vips_icc_transform( in, &t[7],
871+
thumbnail->export_profile,
872+
"input_profile", thumbnail->import_profile,
872873
"intent", thumbnail->intent,
873-
NULL ) )
874-
return( -1 );
875-
in = t[10];
874+
"embedded", TRUE,
875+
NULL ) )
876+
return( -1 );
877+
878+
in = t[7];
879+
}
880+
else {
881+
g_info( "exporting with %s",
882+
thumbnail->export_profile );
883+
if( vips_colourspace( in, &t[7],
884+
VIPS_INTERPRETATION_XYZ, NULL ) ||
885+
vips_icc_export( t[7], &t[10],
886+
"output_profile",
887+
thumbnail->export_profile,
888+
"intent", thumbnail->intent,
889+
NULL ) )
890+
return( -1 );
891+
in = t[10];
892+
}
876893
}
877894
else {
878895
/* We are in one of the resize spaces and there's no export

test/test-suite/helpers/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
IMAGES = os.path.join(os.path.dirname(__file__), os.pardir, 'images')
1111
JPEG_FILE = os.path.join(IMAGES, "sample.jpg")
12+
JPEG_FILE_XYB = os.path.join(IMAGES, "sample-xyb.jpg")
1213
TRUNCATED_FILE = os.path.join(IMAGES, "truncated.jpg")
1314
SRGB_FILE = os.path.join(IMAGES, "sRGB.icm")
1415
MATLAB_FILE = os.path.join(IMAGES, "sample.mat")

test/test-suite/images/sample-xyb.jpg

58.7 KB
Loading

test/test-suite/test_foreign.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,14 +1433,12 @@ def test_jxlsave(self):
14331433

14341434
# scrgb mode
14351435
scrgb = self.colour.colourspace("scrgb")
1436-
no_profile.remove("icc-profile-data")
14371436
self.save_load_buffer("jxlsave_buffer", "jxlload_buffer",
14381437
scrgb, 120)
14391438

14401439
# scrgb mode, no profile
14411440
scrgb_no_profile = scrgb.copy()
14421441
scrgb_no_profile.remove("icc-profile-data")
1443-
no_profile.remove("icc-profile-data")
14441442
self.save_load_buffer("jxlsave_buffer", "jxlload_buffer",
14451443
scrgb_no_profile, 120)
14461444

test/test-suite/test_resample.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import pytest
33

44
import pyvips
5-
from helpers import JPEG_FILE, OME_FILE, HEIC_FILE, TIF_FILE, all_formats, \
6-
have, RGBA_FILE, RGBA_CORRECT_FILE, AVIF_FILE
5+
from helpers import JPEG_FILE, JPEG_FILE_XYB, OME_FILE, HEIC_FILE, TIF_FILE, \
6+
all_formats, have, RGBA_FILE, RGBA_CORRECT_FILE, AVIF_FILE
77

88

99
# Run a function expecting a complex image on a two-band image
@@ -229,6 +229,21 @@ def test_thumbnail(self):
229229
assert thumb.width < thumb.height
230230
assert thumb.height == 100
231231

232+
@pytest.mark.skipif(not pyvips.at_least_libvips(8, 5),
233+
reason="requires libvips >= 8.5")
234+
def test_thumbnail_icc(self):
235+
im = pyvips.Image.thumbnail(JPEG_FILE_XYB, 442, export_profile="srgb", intent="perceptual")
236+
237+
assert im.width == 290
238+
assert im.height == 442
239+
assert im.bands == 3
240+
assert im.bands == 3
241+
242+
# the colour distance should not deviate too much
243+
# (i.e. the embedded profile should not be ignored)
244+
im_orig = pyvips.Image.new_from_file(JPEG_FILE)
245+
assert im_orig.de00(im).max() < 10
246+
232247
def test_similarity(self):
233248
im = pyvips.Image.new_from_file(JPEG_FILE)
234249
im2 = im.similarity(angle=90)

0 commit comments

Comments
 (0)