Closed mceachen closed 2 years ago
Did you see these are already returned by toBuffer()
and toFile()
?
https://sharp.pixelplumbing.com/api-output#tobuffer https://sharp.pixelplumbing.com/api-output#tofile
When using a crop strategy also contains
cropOffsetLeft
andcropOffsetTop
.
Thanks, I'd missed that! That's perfect.
Hello,
Thanks for your work on sharp, @lovell!
Would it be possible to expose the coordinates of the location of interest, not just the crop offset?
@ejoebstl The logic for this lives in smartcrop.c and the "max" score should be the centre of the region returned.
Thanks again for sharp, @lovell ! :100: :1st_place_medal:
What are you trying to achieve?
I'd like to know what coordinates are being considered when cropping with the "attention" strategy
Have you searched for similar feature requests?
Yes, but I couldn't find anything.
What would you expect the API to look like?
Maybe something like
which would return some sort of struct with information used by the crop algorithm, like
What alternatives have you considered?
I could try to pixel-match the cropped result with the same image reduced by the same amount, but that would be expensive.
If you think this request is reasonable, I'd be happy to finalize the API with you and submit a PR.