-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow post-resize crop #23
Comments
Amazing, thanks @lovell, this library is amazingly faster than imagemagick!!/ |
Hi, this would be a great feature. +1 here. Thanks for such an awesome library, just tell me if I could help. |
Once any bugs are fixed and support for Streams is added, cropping is the next feature I plan to work on. Question (for both @tombatossals and @mcgoooo): do you need totally flexibility here or would the gravity-based suggestion of #45 suffice for your needs? If you only require the latter then that might keep the API cleaner (and possibly be quicker/easier to implement). |
Hi @lovell, I think the gravity aproximation will be more than sufficient in my case. I plan to generate thumbs (resized and cropped), and there are some cases where the centered crop approximation is a little short, but if we could specify an optional gravity parameter "south", "center", "north" to the crop function we could give more precision to the thumbnailing functionality. Thanks |
The gravity based one is a good way to go for sure, eventually the option I have a feeling with the streams you may be able to chain the operations
|
For my usage of your library, it would be really useful to be able to specify an offset so that you can customize a region of the image to crop. |
Another thing I noticed is that I wanted to crop the image to a specific size before resizing. I only know the image's width, not the height. But let's say the image is 1024x8000 (it is a screenshot of a full web page) and I want to crop the top 1024x768 (the first screenful), then size that cropped area down to 512x384. |
+1 for custom crop with the ability to select a region of the image, this would be really useful! |
The ability to specify the gravity of the crop will be available in the forthcoming v0.6.0 of this module. See https://github.com/lovell/sharp#cropgravity for the API additions to support this. This should make @tombatossals happy. I plan to use this feature request to focus on the ability to extract a region of the image via offsets, both pre-resize and post-resize as this is what most comments here are looking for. |
That is amazing news, good work 💃
|
Here's a usage example of the API I plan to add to support pre- and post-resize area extraction: sharp(input)
.extract(topOffsetPre, leftOffsetPre, widthPre, heightPre)
.resize(width, height)
.extract(topOffsetPost, leftOffsetPost, widthPost, heightPost)
.toFile(output); If resizing is not required, a simple extraction can be achieved via: sharp(input)
.extract(top, left, width, height)
.toFile(output); Any comments before I go ahead? |
this looks perfect to me :) On Mon, Aug 25, 2014 at 9:32 PM, Lovell Fuller [email protected]
|
Hi @lovell! Thanks so much for writing sharp! It saved me the agony of having to write my own nginx vips filter module :) I also wanted to throw my +1 hat into the ring for a sharp custom crop feature! I've got a sharp-based image re-sizing proxy server ready to publish, I just need to be able to crop images. Thanks again! |
Thanks to some sterling work from @brandonaaron the API described by #23 (comment) is now available on the Please can one (or more) of the participants here check this meets their needs before this is merged to master and released as v0.7.0.
|
This feature is now is master. |
This feature is in v0.7.0, now available via npm. Thanks everyone for all the help and suggestions! |
As requested by @mcgoooo in #8 (comment):
The text was updated successfully, but these errors were encountered: