A WordPress-centric search engine for devs and theme authors



_flip_image_resource ›

Since2.9.0
Deprecated3.5.0
_flip_image_resource ( $img, $horz, $vert )
Parameters: (3)
  • (resource) $img Image resource.
    Required: Yes
  • (bool) $horz Whether to flip horizontally.
    Required: Yes
  • (bool) $vert Whether to flip vertically.
    Required: Yes
See:
  • WP_Image_Editor::flip()
Returns:
  • (resource) (maybe) flipped image resource.
Defined at:
Codex:

Flips an image resource. Internal use only.



Source

function _flip_image_resource( $img, $horz, $vert ) {
	_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' );
	$w   = imagesx( $img );
	$h   = imagesy( $img );
	$dst = wp_imagecreatetruecolor( $w, $h );
	if ( is_resource( $dst ) ) {
		$sx = $vert ? ( $w - 1 ) : 0;
		$sy = $horz ? ( $h - 1 ) : 0;
		$sw = $vert ? -$w : $w;
		$sh = $horz ? -$h : $h;

		if ( imagecopyresampled( $dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) {
			imagedestroy( $img );
			$img = $dst;
		}
	}
	return $img;
}