2

I am working on WordPress plugin. In plugin the user upload images from meta field and in back end i use wp_image_editor for cropping and re sizing the images. The images re sized very well but on cropping the images not cropped very well. I give x-dimension 100 and y-dimension 0.

$resize_img = wp_get_image_editor( $wpc_prod_img['wpc_resize_img'] );
if ( ! is_wp_error( $resize_img ) ) {
   $resize_img->crop( 100, 0, $wpc_image_width, $wpc_image_height, NULL, NULL, false );
}

I want to cropped image from center of x-dimension and center of y-dimension. I tried this but its not work

$resize_img->crop( 'center', 'center', $wpc_image_width, $wpc_image_height, NULL, NULL, false );

How can i do this. Is there any solution

1 Answer 1

2

Try this code

$crop = array( 'center', 'center' );
$resize_img->resize( $wpc_image_width, $wpc_image_height, $crop);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.