How to change crop location
-
ImageMagick Engine will ignore the settings you have for custom image sizes with crop location, because ImageMagick Engine is not using the default WordPress cropThumbnailImage() function as it strips profile data.
For example I have this custom image size, with a horizontal center and a vertical top crop location:
add_image_size( 'square', 250, 250, array( 'center', 'top' ) );
For making ImageMagick Engine to crop the image as above, in imagemagick-engine.php line 438 I changed this:
$off_y = ceil( ( $orig_height - $crop_height ) / 2 );
into this:
$off_y = 0; /* ceil( ( $orig_height - $crop_height ) / 2 ); */
It’s just replacing ceil( ( $orig_height – $crop_height ) / 2 ); with 0
If you want to change crop location to LEFT and TOP, change ALSO this:
$off_x = ceil( ( $orig_width - $crop_width ) / 2 );
into this:
$off_x = 0; /* ceil( ( $orig_width - $crop_width ) / 2 ); */
NOTES:
– ImageMagick Engine will apply the changes to all image sizes that HAVE crop enabled, even for default image sizes like thumbnail, medium, medium_large, large; from my point of view that’s a good thing because usually WP doesn’t allow easily to change the crop location for default image sizes ??
– you can use only one setting, so if you have two crop location defind like this:add_image_size( 'square', 250, 250, array( 'center', 'top' ) ); add_image_size( 'square', 500, 500, array( 'left', 'top' ) );
ImageMagick will ignore your custom settings and only apply the modifications you made inside imagemagick-engine.php. In fact, you even don’t have to define an add_image_size custom crop location at all.
Hope it helps.
- The topic ‘How to change crop location’ is closed to new replies.