add a test for unpremultiply

we actually test vipsthumbnail --linear on an RGBA image, which should
catch everything, hopefully
This commit is contained in:
John Cupitt 2021-02-27 15:48:02 +00:00
parent d3ccadf212
commit 0b74acf7ba
4 changed files with 14 additions and 1 deletions

View File

@ -42,6 +42,8 @@ BMP_FILE = os.path.join(IMAGES, "MARBLES.BMP")
NIFTI_FILE = os.path.join(IMAGES, "avg152T1_LR_nifti.nii.gz")
ICO_FILE = os.path.join(IMAGES, "favicon.ico")
HEIC_FILE = os.path.join(IMAGES, "heic-orientation-6.heic")
RGBA_FILE = os.path.join(IMAGES, "rgba.png")
RGBA_CORRECT_FILE = os.path.join(IMAGES, "rgba-correct.ppm")
MOSAIC_FILES = [os.path.join(IMAGES, "cd1.1.jpg"), os.path.join(IMAGES, "cd1.2.jpg"),
os.path.join(IMAGES, "cd2.1.jpg"), os.path.join(IMAGES, "cd2.2.jpg"),
os.path.join(IMAGES, "cd3.1.jpg"), os.path.join(IMAGES, "cd3.2.jpg"),

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -2,7 +2,8 @@
import pytest
import pyvips
from helpers import JPEG_FILE, OME_FILE, HEIC_FILE, TIF_FILE, all_formats, have
from helpers import JPEG_FILE, OME_FILE, HEIC_FILE, TIF_FILE, all_formats, \
have, RGBA_FILE, RGBA_CORRECT_FILE
# Run a function expecting a complex image on a two-band image
@ -193,6 +194,11 @@ class TestResample:
im2 = pyvips.Image.thumbnail_buffer(buf, 100)
assert abs(im1.avg() - im2.avg()) < 1
# linear shrink should work on rgba images
im1 = pyvips.Image.thumbnail(RGBA_FILE, 64, linear=True)
im2 = pyvips.Image.new_from_file(RGBA_CORRECT_FILE)
assert abs(im1.flatten(background=255).avg() - im2.avg()) < 1
if have("heifload"):
# this image is orientation 6 ... thumbnail should flip it
im = pyvips.Image.new_from_file(HEIC_FILE)