图片X翻转
<?php
function flipX($imgname){
list($w,$h,$imgType) = getimagesize($imgname);
$types = array('1' => 'gif', '2' => 'jpeg', '3' => 'png' );
$createImg = 'imagecreatefrom'.$types[$imgType];
$img = $createImg($imgname);
$dimg = imagecreatetruecolor($w, $h);
for ($y=0; $y < $h; $y++) {
imagecopy($dimg, $img, 0, $h-$y-1, 0, $y, $w, 1);
}
$save = 'image'.$types[$imgType];
$save($dimg, 'new_' . $imgname);
imagedestroy($img);
imagedestroy($dimg);
}
flipX('logo.png');
图片Y翻转
function flipY($imgname){
list($w,$h,$imgType) = getimagesize($imgname);
$types = array('1' => 'gif', '2' => 'jpeg', '3' => 'png' );
$createImg = 'imagecreatefrom'.$types[$imgType];
$img = $createImg($imgname);
$dimg = imagecreatetruecolor($w, $h);
for ($x=0; $x < $w; $x++) {
imagecopy($dimg, $img, $w-$x-1, 0, $x, 0, 1, $h);
}
$save = 'image'.$types[$imgType];
$save($dimg, 'new_' . $imgname);
imagedestroy($img);
imagedestroy($dimg);
}
flipY('me.jpg');
?>
图片旋转
<?php
function rotate($imgname,$angle){
list($sw,$sh,$imgType) = getimagesize($imgname);
$types = array('1' => 'gif', '2' => 'jpeg', '3' => 'png' );
$createImg = 'imagecreatefrom'.$types[$imgType];
$img = $createImg($imgname);
$dimg = imagerotate($img, $angle,0);
$save = 'image'.$types[$imgType];
$save($dimg, 'new_' . $imgname);
imagedestroy($img);
imagedestroy($dimg);
}
rotate('logo.png',-60);
?>