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

feat: add cropping via vips #37

Merged
merged 1 commit into from
Dec 2, 2024
Merged

feat: add cropping via vips #37

merged 1 commit into from
Dec 2, 2024

Conversation

knarewski
Copy link
Contributor

Background

GdkPixbuf-based image processing can take over 1GB of memory for processing a single high-resolution photo. We've decided to introduce another processor, hoping that it'll improve Morandi's memory profile and performance.

Problems

Vips processor doesn't support cropping

Solution

Add support for cropping

Pixbuf vs Vips comparison

image
Input image
Simple cropping (left - pixbuf, right - vips), mean average error: 0.0107107
Cropping outside the image dimensions (left - pixbuf, right - vips), mean average error: 0.00950674

Other images can be compared by opening files with identical names in spec/fixtures/reference_images/ and spec/fixtures/reference_images/vips/

Libvips crop output appears to be more noisy, but after visual inspection it seems to be more similar to the original

Base automatically changed from feat-add-vips-colour-filters to master November 29, 2024 11:22
The difference in reference images:
- plasma-cropped-excessive-size - MAE (mean average error): 0.00950674
- plasma-cropped - MAE: 0.0107107
- plasma-cropped-negative-initial-coords - MAE: 0.00959682
- plasma-cropped-1x1 - no difference, duplicated in vips directory for completeness
- plasma-auto-cropped - MAE: 0.0181914 , also one pixel difference in height (pixbuf trims 243.75 down, vips rounds it up)
                        it also required adding tolerance due to differences between vips used on development and CI; (MAE: 0.00480813)

Libvips crop output appears a bit more noisy, but it seems to better resemble the original
@knarewski knarewski marked this pull request as ready for review November 29, 2024 12:52
@knarewski knarewski requested a review from a team November 29, 2024 12:52
@knarewski knarewski merged commit cd0797e into master Dec 2, 2024
15 checks passed
@knarewski knarewski deleted the feat-add-vips-crop branch December 2, 2024 09:47
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