图片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(dst_im, src_im, dst_x, dst_y, src_x, src_y, src_w, src_h)
            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(dst_im, src_im, dst_x, dst_y, src_x, src_y, src_w, src_h)
            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);

 ?>