WordPress at Your Fingertips
function is not described

_flip_image_resource() WP 2.9.0

Deprecated from version 3.5.0. It is no longer supported and can be removed in future releases. Use WP_Image_Editor::flip() instead.

Flips an image resource. Internal use only.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.

Return

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

Usage

_flip_image_resource( $img, $horz, $vert );
$img(resource|GdImage) (required)
Image resource or GdImage instance.
$horz(true|false) (required)
Whether to flip horizontally.
$vert(true|false) (required)
Whether to flip vertically.

Notes

Changelog

Since 2.9.0 Introduced.
Deprecated Since 3.5.0 Use WP_Image_Editor::flip()

Code of _flip_image_resource() WP 5.8.2

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_gd_image( $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;
}