当前位置:编程学习 > php >>

图象翻转

答案:<?php
/**
flip 图象翻转
**/

$image = "images/csdn.gif"; // 原图
$imgstream = file_get_contents($image);
$im = imagecreatefromstring($imgstream);

$thumbw = imagesx($im); // 原图宽
$thumbh = imagesy($im); // 原图高

if(function_exists("imagecreatetruecolor"))
$dim = imagecreatetruecolor($thumbw, $thumbh); // 创建目标图gd2
else
$dim = imagecreate($thumbh, $thumbw); // 创建目标图gd1
for($x=0;$x<$thumbw;$x++)
for($y=0;$y<$thumbh;$y++) {
// imagecopyresized($dim,$im,$thumbw-$x-1,$y,$x,$y,1,1,1,1); //水平翻转
imagecopyresized($dim,$im,$x,$thumbh-$y-1,$x,$y,1,1,1,1); //垂直翻转
}


header ("Content-type: image/jpeg");
imagejpeg ($dim);
?>

上一个:PHP实际操作中权限问题小结
下一个:关于PHP中的Class的几点个人看法

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,