Skip to content
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

test: add specs for non-rgb image processing #32

Merged
merged 7 commits into from
Nov 14, 2024
Merged

Conversation

knarewski
Copy link
Contributor

Background
I'm prototyping libvips-based Morandi on a separate branch in hope of improving its memory profile and performance.

Problems
Pixbuf automatically converts everything to RGB, but libvips doesn't. We want to ensure that when non-RGB images are supplied, they are processed correctly and provide sRGB output by default.

Solutions
Add basic test coverage for processing a non-RGB image (in this case it's 1-channel - greyscale).

On top of basic test, I added a second simple test case, because colour filters rely on some RGB constants and fail for non-RGB images when implemented incorrectly.

The other differently handled option is cropping outside of image boundaries, but I consider that edge case not worthy of a dedicated test at the moment

Notes

  • I also added a new rspec matcher and some small improvements in the tests area

It makes debugging single tests easier
this will allow to reuse code when generating grayscale image for test I am about to write
When fixtures were used, the image was outside sample/ directory and was not added to visual report as expected,
leading to harder debugging
Pixbuf happens to convert everything to RGB, but other processors are not guaranteed to have such property,
thus the additional specs.

I've also added a new matcher to make colourspace check easy.
Due to using file_arg instead of file_in, the previous solution was unnecessarily generating
plasma image and displayed a wrong input image in visual report, now it is fixed

It also makes the code simpler and more consistent with generation of other images
Copy link
Contributor

@MrLukeSmith MrLukeSmith left a comment

Choose a reason for hiding this comment

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

I think I might have been pushing my luck, trying to review this so late in the day. It's been a long day... But after a couple of reads through, I'm good. 😅 😂

Looks like a solid improvement. 🏅

@knarewski knarewski merged commit e71f633 into master Nov 14, 2024
15 checks passed
@knarewski knarewski deleted the test-non-rgb-support branch November 14, 2024 17:03
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