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

Add the option to use background and threshold options on trim #206

Merged
merged 2 commits into from
Nov 23, 2017

Conversation

tstm
Copy link
Contributor

@tstm tstm commented Nov 9, 2017

The trim function in libvips accepts optional parameters Background and Threshold, which can be quite important when trimming an image. The background is used to choose the color to actually trim away, and threshold is the amount of difference allowed, see here

This should add those parameters, directly from the Options struct just as other such parameters.

One extra thing to add would be to have an option to detect the color to be used from ie. the top left pixel, to work with previously unknown images. This is also a feature I need.

@tstm
Copy link
Contributor Author

tstm commented Nov 23, 2017

Is there some way I could help or further things along to get this merged?

@h2non h2non merged commit 03f7d1f into h2non:master Nov 23, 2017
@h2non
Copy link
Owner

h2non commented Nov 23, 2017

Sorry for the latency here. Ping me if I do not answer a PR in a few days.

err := C.vips_find_trim_bridge(image,
&top, &left, &width, &height,
C.double(background.R), C.double(background.G), C.double(background.B),
C.double(threshold))
Copy link
Contributor

Choose a reason for hiding this comment

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

float32 and C.double ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh no! You're right. Should be float64 here, it's used as a double in libvips.

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.

3 participants