I would like to resize the WordPress image programmatically via my custom WordPress plugin
You can use default WordPress function wp_get_image_editor
$image = wp_get_image_editor( 'image.jpg' ); if ( ! is_wp_error( $image ) ) { $image->rotate( 120 ); $image->resize( 200, 200, true ); $image->save( 'new_image.jpg' ); }
Thanks for the code snippet it saved me many hours.
I needed to resize uploaded custom profile images for a membership website we are building and the images are uploaded into a custom folder. This code really helped, I adapted it to our use case: upload the image, resize & save a new copy, them delete the original image to save space.
Thanks, if you have any WordPress questions, you can ask here.