dth20986 2012-10-15 07:38
浏览 131

imagecopy无法正常工作

I was trying to form an image from multiple images that fall under a certain pattern. but in the end I only get a gray box and the date, despite the fact that the array of found images is not empty.

$name = $_GET['gn'];
$dest = 'images/sprites/';
$images = array();
$dir = getcwd() . '/images/thumb';

$dir_b = $dir.'/real-size';

$pattern = $dir_b.'/{'.$name.'}*.jpg';
$images = glob($pattern,GLOB_BRACE);
list($step_w,$step_h) = getimagesize($images[0]);

$fi = imagecreate($step_w*count($images), $step_h);
$bg = imagecolorallocate($fi, 200, 200, 200);
imagefill($fi, 0, 0, $bg);
imagealphablending($fi, false);
imagesavealpha($fi, true);
ksort($images);

foreach($images as $k => $i){
    $pi =  imagecreatefromjpeg($i);
    imagecopy($fi,$pi,$k*$step_w,0,0,$step_w,$step_h);  
    imagedestroy($pi);
}
$textcolor = imagecolorallocate($fi, 0, 0, 255);

imagestring($fi, 5, 0, 0, date('H:i:s'), $textcolor);

imagepng($fi, $dest.$name.'.png');
imagedestroy($fi);

Where is the mistake and what can i do to fix it?

After some comments: I can safely say that the cycle passes all four times, each time a variable $pi is taking valid value

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源
    • ¥15 安卓JNI项目使用lua上的问题
    • ¥20 RL+GNN解决人员排班问题时梯度消失