deliciousbrains / wp-image-processing-queue

Resize WordPress images in the background
203 stars 18 forks source link

Support for focal point (crop/background position) #21

Open JiveDig opened 4 years ago

JiveDig commented 4 years ago

First off, thanks for this library, it seems extremely useful!

When generating images to be used as a background image (Cover Block, etc) there are 2 requirements in order to use this library:

  1. Allow different aspect ratios at different window sizes (pretty sure this already works).

  2. Allow a focal point so different sizes are cropped in the correct location.

Since the block editor now has and uses this https://developer.wordpress.org/block-editor/components/focal-point-picker/ It would be super useful to be able to pass the focal point (in relation to the original image) and have the additional image sizes use this focal point when generating new images.

Maybe there is a better solution, but either way it would be great to insure the focal point is always centered on all the images.

JiveDig commented 4 years ago

Looking into WP_Image_Editor class, it seems like crop() method handles this pretty well. Maybe this could be integrated here.