Thanks to visit codestin.com
Credit goes to github.com

Skip to content

test and fix SAVEABLE #4495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

test and fix SAVEABLE #4495

wants to merge 10 commits into from

Conversation

jcupitt
Copy link
Member

@jcupitt jcupitt commented May 1, 2025

vips__foreign_convert_saveable() doesn't seem to work for all image types, start testing it more carefully.

test_matrix tests matrixsave, which uses SAVEABLE_MONO ... test conversion of all image types.

vips__foreign_convert_saveable() doesn't seem to work for all image
types, start testing it more carefully.

test_matrix tests matrixsave, which uses SAVEABLE_MONO ... test
conversion of all image types
@jcupitt jcupitt marked this pull request as draft May 1, 2025 13:26
@jcupitt jcupitt changed the title testing and fix SAVEABLE test and fix SAVEABLE May 1, 2025
@jcupitt
Copy link
Member Author

jcupitt commented May 2, 2025

Sample bug in master from these problems -- RGB to mono works OK:

$ vips copy k2.jpg x.csv
$ vipsheader x.csv
x.csv: 1450x2048 double, 1 band, b-w, csvload

So the SAVEABLE_MONO tag on csvsave is successfully converting RGB to mono before the save, but:

$ vipsheader lion.png 
lion.png: 425x425 uchar, 4 bands, srgb, pngload
$ vips copy lion.png x.csv
csvsave_target: image must one band

It fails for RGBA. The saveable system needs simplifying and testing more carefully.

@jcupitt jcupitt marked this pull request as ready for review May 7, 2025 08:26
@jcupitt
Copy link
Member Author

jcupitt commented May 7, 2025

This replaces the old VipsSaveable enum with a set of VipsForeignSaveable flags. Savers set flags for the image types they support, eg. MONO | RGB | ALPHA etc. There's an implementation of VipsSaveable for compat, though libvips itself no longer uses it.

The conversion to a saveable image type is supposed to be simpler and easier to understand and verify. There are a lot more tests!

This fixes quite a few obscure bugs, as noted in the top comment.

@kleisauke
Copy link
Member

CIFuzz caught an interesting fuzzer bug in this PR. You can download the reproducer here:
https://github.com/libvips/libvips/actions/runs/14878870815?pr=4495

$ vipsheader crash-c8c0ef1d5d8a06465e3a728c0cd8d37b59239cbe
crash-c8c0ef1d5d8a06465e3a728c0cd8d37b59239cbe: 1x1 dpcomplex, 1 band, error
$ vips copy crash-c8c0ef1d5d8a06465e3a728c0cd8d37b59239cbe x.jpg
Aborted (core dumped)

VIPS_SAVEABLE_RGB | VIPS_FOREIGN_SAVEABLE_CMYK,
VIPS_SAVEABLE_ANY =
VIPS_FOREIGN_SAVEABLE_ANY,
VIPS_SAVEABLE_LAST = 99,
} VipsSaveable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could still move this to almostdeprecated.h and alias vips_saveable_get_type() to vips_foreign_saveable_get_type() for compat, see e.g. commit kleisauke@865d67c. Not sure if that's the right approach, though.

jcupitt and others added 2 commits May 7, 2025 12:53
Co-authored-by: Kleis Auke Wolthuizen <[email protected]>
vips_image_guess_format() could return a bad format for
VIPS_INTERPRETATION_ERROR. Fixes a fuzzing fail.
@jcupitt
Copy link
Member Author

jcupitt commented May 7, 2025

CIFuzz caught an interesting fuzzer bug in this PR.

It was a nasty bug in vips_image_guess_format(). Good to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants