Voting

: max(five, four)?
(Example: nine)

The Note You're Voting On

xafford
16 years ago
concerning the previous post of Borszczuk and the function to mirror images:

There´s a way better (and faster) method for this task with imagecopyresampled.

<?php

define
( 'IMAGE_FLIP_HORIZONTAL', 1 );
define ( 'IMAGE_FLIP_VERTICAL', 2 );
define ( 'IMAGE_FLIP_BOTH', 3 );

function
ImageFlip ( $imgsrc, $mode )
{

$width = imagesx ( $imgsrc );
$height = imagesy ( $imgsrc );

$src_x = 0;
$src_y = 0;
$src_width = $width;
$src_height = $height;

switch ( (int)
$mode )
{

case
IMAGE_FLIP_HORIZONTAL:
$src_y = $height;
$src_height = -$height;
break;

case
IMAGE_FLIP_VERTICAL:
$src_x = $width;
$src_width = -$width;
break;

case
IMAGE_FLIP_BOTH:
$src_x = $width;
$src_y = $height;
$src_width = -$width;
$src_height = -$height;
break;

default:
return
$imgsrc;

}

$imgdest = imagecreatetruecolor ( $width, $height );

if (
imagecopyresampled ( $imgdest, $imgsrc, 0, 0, $src_x, $src_y, $width, $height, $src_width, $src_height ) )
{
return
$imgdest;
}

return
$imgsrc;

}

?>

<< Back to user notes page

To Top