【问题标题】:display from file using imagick library in php在 php 中使用 imagick 库从文件中显示
【发布时间】:2012-05-15 04:21:05
【问题描述】:

你能帮帮我吗?

我编写了以下代码来显示目录中的字母图像,我通过 linux 终端上的 CLI 运行此代码,但我什么也没有得到没有图像显示??!!

这是代码:

<?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 );


}

?>

谢谢亲爱的;

【问题讨论】:

  • 应该如何在 linux shell 中显示图像? ps:我在代码中没有看到任何echo
  • 我试图放回声,但我得到垃圾数据而不是图像所以请告诉我我可以把它放在哪里或如何??
  • 我重复我的问题:它应该如何在 linux shell 中显示图像?
  • 抱歉,我可以t understand ur question, but i wanna to run my code using CLI, sorry if i dont 理解你,但我是 php 和 imagick 的新手
  • 我的问题根本与 php 无关。你见过任何显示linux shell的图片吗?

标签: php image imagemagick imagick


【解决方案1】:

您好,我只是想向您展示我的问题的正确代码,最后我做到了:-

<?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);

 ?>

【讨论】:

    猜你喜欢
    • 2021-08-10
    • 2021-02-19
    • 1970-01-01
    • 1970-01-01
    • 2013-08-12
    • 2013-04-29
    • 1970-01-01
    • 1970-01-01
    • 2017-01-22
    相关资源
    最近更新 更多