dqwh0108 2012-05-06 07:14
浏览 11

使用php中的imagick库从文件中显示

can you help me please ?

i wrote the following code to display the alphabet images from directory and i run this code through CLI on linux terminal and i get nothing no image displayed ??!!

this is the code:

<?php
$name='LUBNA';
$length=  strlen($name);
$name_array=array();
$image_path='/var/www/letters/';

for($i=0; $i<$length; $i++) {

    $name_array[$i]=$name[$i];

}


    foreach ($name_array as $value) 
    {

        $image = $image_path.$value.'.png';

        $im = new Imagick();

        $im->readImage( $image );


}

?>

thanks dears;

  • 写回答

1条回答 默认 最新

  • dongyao1895 2012-05-07 08:58
    关注

    Hello just wanna show you the correct code of my question finally i did it :-

    <?php
    
    $name='lubna';
    $name=strtoupper($name);
    $length=  strlen($name);
    $name_array=array();
    $image_path='/var/www/letters/';
    
    $image_array=array();
    $image_hight=array();
    for($i=0; $i<$length; $i++) {
    
        $name_array[$i]=$name[$i];
        $image_array[$i]=$image_path.$name[$i].'.png';
        $size=  getimagesize($image_array[$i]);
        $hight=$size[1];
        $image_hight[$i]=$hight;
    
    }
    
    $hight1=  array_sum($image_hight);
    $image = new Imagick();
    $image->newImage(120, $hight1, new ImagickPixel('none'));
    $image->setImageFormat('png');
    $offset=0;
    
      foreach($name_array as $id=>$value) 
       {  
    
        $img= new Imagick($image_path.$value.'.png');
    
        $image->compositeimage($img, imagick::COMPOSITE_COPY,0, $offset);
    
        $offset=$offset+$image_hight[$id];
       }
    //header('Content-type: image/png');
    //echo $image;
       $image->setImageFormat('png');
       $image->writeimage('/tmp/name.png');
       $cmd1="display /tmp/name.png";
       $run1=  exec($cmd1);
    
     ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)