A WordPress-centric search engine for devs and theme authors



_crop_image_resource ›

Since2.9.0
Deprecatedn/a
_crop_image_resource ( $img, $x, $y, $w, $h )
Parameters: (5)
  • (resource) $img Image resource.
    Required: Yes
  • (float) $x Source point x-coordinate.
    Required: Yes
  • (float) $y Source point y-cooredinate.
    Required: Yes
  • (float) $w Source width.
    Required: Yes
  • (float) $h Source height.
    Required: Yes
Returns:
  • (resource) (maybe) cropped image resource.
Defined at:
Codex:

Crops an image resource. Internal use only.



Source

function _crop_image_resource( $img, $x, $y, $w, $h ) {
	$dst = wp_imagecreatetruecolor( $w, $h );
	if ( is_resource( $dst ) ) {
		if ( imagecopy( $dst, $img, 0, 0, $x, $y, $w, $h ) ) {
			imagedestroy( $img );
			$img = $dst;
		}
	}
	return $img;
}