parent
d1094847a3
commit
72c103f95a
@ -1,6 +1,5 @@
|
||||
20/6/19 started 8.9.0
|
||||
- add vips_image_get/set_array_int()
|
||||
- remove support for no-alpha webp images, it didn't work well
|
||||
|
||||
24/5/19 started 8.8.1
|
||||
- improve realpath() use on older libc
|
||||
|
@ -20,9 +20,6 @@
|
||||
* 30/4/19
|
||||
* - deprecate shrink, use scale instead, and make it a double ... this
|
||||
* lets us do faster and more accurate thumbnailing
|
||||
* 27/6/19
|
||||
* - remove non-alpha output: it's very hard to decide if a webp image
|
||||
* really has zero transparency
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -110,6 +107,10 @@ typedef struct {
|
||||
int frame_width;
|
||||
int frame_height;
|
||||
|
||||
/* TRUE for RGBA.
|
||||
*/
|
||||
int alpha;
|
||||
|
||||
/* Number of frames in file.
|
||||
*/
|
||||
int frame_count;
|
||||
@ -445,10 +446,11 @@ read_header( Read *read, VipsImage *out )
|
||||
|
||||
flags = WebPDemuxGetI( read->demux, WEBP_FF_FORMAT_FLAGS );
|
||||
|
||||
/* The alpha flag says if this square of pixels in this frame has an
|
||||
* alpha, not if our output image should have an alpha.
|
||||
*/
|
||||
read->config.output.colorspace = MODE_RGBA;
|
||||
read->alpha = flags & ALPHA_FLAG;
|
||||
if( read->alpha )
|
||||
read->config.output.colorspace = MODE_RGBA;
|
||||
else
|
||||
read->config.output.colorspace = MODE_RGB;
|
||||
|
||||
if( flags & ANIMATION_FLAG ) {
|
||||
int loop_count;
|
||||
@ -532,7 +534,8 @@ read_header( Read *read, VipsImage *out )
|
||||
|
||||
read->frame = vips_image_new_memory();
|
||||
vips_image_init_fields( read->frame,
|
||||
read->frame_width, read->frame_height, 4,
|
||||
read->frame_width, read->frame_height,
|
||||
read->alpha ? 4 : 3,
|
||||
VIPS_FORMAT_UCHAR, VIPS_CODING_NONE,
|
||||
VIPS_INTERPRETATION_sRGB,
|
||||
1.0, 1.0 );
|
||||
@ -542,7 +545,8 @@ read_header( Read *read, VipsImage *out )
|
||||
return( -1 );
|
||||
|
||||
vips_image_init_fields( out,
|
||||
read->width, read->height, 4,
|
||||
read->width, read->height,
|
||||
read->alpha ? 4 : 3,
|
||||
VIPS_FORMAT_UCHAR, VIPS_CODING_NONE,
|
||||
VIPS_INTERPRETATION_sRGB,
|
||||
1.0, 1.0 );
|
||||
@ -594,7 +598,8 @@ read_frame( Read *read,
|
||||
|
||||
frame = vips_image_new_memory();
|
||||
vips_image_init_fields( frame,
|
||||
width, height, 4,
|
||||
width, height,
|
||||
read->alpha ? 4 : 3,
|
||||
VIPS_FORMAT_UCHAR, VIPS_CODING_NONE,
|
||||
VIPS_INTERPRETATION_sRGB,
|
||||
1.0, 1.0 );
|
||||
|
@ -23,7 +23,6 @@ class TestForeign:
|
||||
cls.tempdir = tempfile.mkdtemp()
|
||||
|
||||
cls.colour = pyvips.Image.jpegload(JPEG_FILE)
|
||||
cls.rgba = cls.colour.bandjoin(255)
|
||||
cls.mono = cls.colour.extract_band(1)
|
||||
# we remove the ICC profile: the RGB one will no longer be appropriate
|
||||
cls.mono.remove("icc-profile-data")
|
||||
@ -464,22 +463,22 @@ class TestForeign:
|
||||
def test_webp(self):
|
||||
def webp_valid(im):
|
||||
a = im(10, 10)
|
||||
assert_almost_equal_objects(a, [70, 165, 235, 255])
|
||||
assert_almost_equal_objects(a, [71, 166, 236])
|
||||
assert im.width == 550
|
||||
assert im.height == 368
|
||||
assert im.bands == 4
|
||||
assert im.bands == 3
|
||||
|
||||
self.file_loader("webpload", WEBP_FILE, webp_valid)
|
||||
self.buffer_loader("webpload_buffer", WEBP_FILE, webp_valid)
|
||||
self.save_load_buffer("webpsave_buffer", "webpload_buffer",
|
||||
self.rgba, 60)
|
||||
self.save_load("%s.webp", self.rgba)
|
||||
self.colour, 60)
|
||||
self.save_load("%s.webp", self.colour)
|
||||
|
||||
# test lossless mode
|
||||
im = pyvips.Image.new_from_file(WEBP_FILE)
|
||||
buf = im.webpsave_buffer(lossless=True)
|
||||
im2 = pyvips.Image.new_from_buffer(buf, "")
|
||||
assert abs(im.avg() - im2.avg()) < 1
|
||||
assert im.avg() == im2.avg()
|
||||
|
||||
# higher Q should mean a bigger buffer
|
||||
b1 = im.webpsave_buffer(Q=10)
|
||||
|
Loading…
Reference in New Issue
Block a user