It would be nice when embed gets a gravity argument
so the image can be placed to a side or corner instead only centered.
Hi, this seems like an old Issue, is it still up for grabs? I have read the contributing guide and will begin going through the code today.
@AzureByte Yes, thank you, PRs always welcome. if you haven't already spotted it, the suit branch contains the work-in-progress for the next v0.19.0 release so you may want to use that as your base.
I've managed to get the functionality of embedding done. However, I am having trouble passing a parameter via the javascript 'embed' function to C++ I tried following on how it was done with crop and it looks almost identical but I think I'm missing something.
@AzureByte Thank you. Is there a work-in-progress fork/branch I can look at to help?
@lovell Sure! I've pushed what I've done so far to https://github.com/AzureByte/sharp/tree/feature/embedgravity Thanks
@AzureByte Thanks, I'll take a look later this week.
@AzureByte Assigning baton->embed within NAN_METHOD(pipeline) approximately here should help you progress.
@lovell Thanks for that! I was wondering what I was missing. Have a better idea of what is happening now.
Was able to spend some time today to work on it. Managed to get what I think is the required functionality. Please see the attached screenshot.

The original image is a screenshot of 1920x1080px and run through using the function
sharp('./input/original.png')
.resize(<width,height>)
.background({r: 0, g: 0, b: 0, alpha: 0})
.embed(sharp.gravity.<direction>)
.toFile(...);
Two sets of images were generated, each set having each of the different directions available via sharp.gravity including entropy.
The first set of images was run through using
Pushed my changes to https://github.com/AzureByte/sharp/tree/feature/embedgravity If the screenshot linked looks good, I'll go ahead and add the relevant unit test cases before submitting a PR.
@AzureByte Those images look great, thank you for working on this. I'm not sure the entropy and attention strategies make sense when embedding so we can probably leave those out.
Hi @lovell sorry about the wait, I had some trouble getting the unit tests to work and then I was at a conference for a week.
Submitted a pull request here #1032 Left out the entropy/attention strategies from the unit tests.
Thanks to @AzureByte this will be in v0.19.0.
sharp v0.19.0 is now available, thanks @AzureByte !