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

Is an 'auto-crop' feature scheduled? #70

Closed
marcolino opened this issue Nov 15, 2015 · 9 comments
Closed

Is an 'auto-crop' feature scheduled? #70

marcolino opened this issue Nov 15, 2015 · 9 comments

Comments

@marcolino
Copy link
Contributor

Is an auto-crop feature scheduled any point in time?

I mean: some images have one-color borders, which can be sometimes annoying, something that distracts from the real image contents...

I suppose it should not be so difficult, to implement (knowing the inners of jimp... :-): you should check the colors of the most external pixel for each one of the four borders: if they are all the same, you should crop that side by one pixel, and continue with the next pixel...

As an edge case, you could finish with an empty image (if the source image was just one color)... That should be fine, of course (auto-cropping one-color image is a quite silly operation in itself... :-).

For example, from:
amb

to:
am

@gcq
Copy link
Contributor

gcq commented Nov 15, 2015

jimp is so lowe level and so straightforward to use that a feature like that, so specific, would not add much value and instead add complexity.

You layed out the algorithm, now it's a matter of implementing it 😄

@marcolino
Copy link
Contributor Author

Yup! I did never read throughtfully jimp docs, now I see there is a getPixelColor(x, y) method... So yes, I'll try to implement an autocrop() method myself... Or should I directly use bitmap data, to improve performance?

@oliver-moran
Copy link
Collaborator

@marcolino, I'm happy to include in an auto-crop method. If you implement it and make a pull request, I'll happily pull it in. Alternatively, if you can write a simple method using the API and post it here, I'll add it to the code base.

@marcolino
Copy link
Contributor Author

Hi!
I'm trying to git push origin autocrop-branch, to easily create a PR, but am I supposed to know repository authentication, to push a branch?

@oliver-moran
Copy link
Collaborator

  1. Create a fork by clicking the link in the top right here: https://github.com/oliver-moran/jimp
  2. Check that out, make your modifications and save your changes to the fork.
  3. Then go here and create a new pull request: https://github.com/oliver-moran/jimp/pulls

@marcolino
Copy link
Contributor Author

Yes... I forgot to fork, but did clone directly from your repo... :-(
Sorry, it's a long time from my last PR... :-)
Please let me now what you think about the autocrop feature...

@oliver-moran
Copy link
Collaborator

Merged the pull request here: #71

Thanks!

@marcolino
Copy link
Contributor Author

Sorry, last question: I have already some minor changes to autocrop... Should I create a new PR, or what?

@oliver-moran
Copy link
Collaborator

Sure thing, just create a new pull request from the fork you have.

I think you might even be able to do it in the same thread: #71

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

No branches or pull requests

3 participants