_crop_image_resource()
Crops an image resource. Internal use only.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
resource|GdImage
. (maybe) cropped image resource or GdImage instance.
Usage
_crop_image_resource( $img, $x, $y, $w, $h );
- $img(resource|GdImage) (required)
- Image resource or GdImage instance.
- $x(float) (required)
- Source point x-coordinate.
- $y(float) (required)
- Source point y-coordinate.
- $w(float) (required)
- Source width.
- $h(float) (required)
- Source height.
Changelog
Since 2.9.0 | Introduced. |
_crop_image_resource() crop image resource code WP 6.6.2
function _crop_image_resource( $img, $x, $y, $w, $h ) { $dst = wp_imagecreatetruecolor( $w, $h ); if ( is_gd_image( $dst ) ) { if ( imagecopy( $dst, $img, 0, 0, $x, $y, $w, $h ) ) { imagedestroy( $img ); $img = $dst; } } return $img; }