_crop_image_resource() – Crops an image resource. Internal use only.

You appear to be a bot. Output may be restricted

Description

Crops an image resource. Internal use only.

Usage

$resource|GdImage = _crop_image_resource( $img, $x, $y, $w, $h );

Parameters

$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.

Returns

resource|GdImage (maybe) cropped image resource or GdImage instance.

Source

File name: wordpress/wp-admin/includes/image-edit.php
Lines:

1 to 12 of 12
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;
}
 

 View on GitHub View on Trac