BP_Media_Rotation::flip_image( $image )

Flips the image

Description

Parameters

$image

(Required)

Return

(bool)

Source

File: bp-media/classes/class-bp-media-rotation.php

		function flip_image( &$image ) {
			$x      = 0;
			$y      = 0;
			$height = null;
			$width  = null;

			if ( $width < 1 ) {
				$width = imagesx( $image );
			}

			if ( $height < 1 ) {
				$height = imagesy( $image );
			}

			if ( function_exists( 'imageistruecolor' ) && imageistruecolor( $image ) ) {
				$tmp = imagecreatetruecolor( 1, $height );
			} else {
				$tmp = imagecreate( 1, $height );
			}

			$x2 = $x + $width - 1;

			for ( $i = (int) floor( ( $width - 1 ) / 2 ); $i >= 0; $i -- ) {
				imagecopy( $tmp, $image, 0, 0, $x2 - $i, $y, 1, $height );
				imagecopy( $image, $image, $x2 - $i, $y, $x + $i, $y, 1, $height );
				imagecopy( $image, $tmp, $x + $i, $y, 0, 0, 1, $height );
			}

			imagedestroy( $tmp );

			return true;
		}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.