duanke1286 2010-12-12 19:23
浏览 75

PHP:用passthru显示图像比在磁盘中创建图像更好

i need display modyfied image , i have 2 option as i see it to create temp image that is modified and then delete it or to create the image on the fly and display it with passthru for example :

$photo="foo.jpg";
$THUMB_SZ  = 125;
$THUMB_PRESZ  = $THUMB_SZ * 2;
$QUALITY = 87;
$convert = "/usr/bin/convert";
$command = "$convert -size $THUMB_PRESZ".'x'."$THUMB_PRESZ \"$photo\"" .
        " -thumbnail $THUMB_SZ".'x'."$THUMB_SZ" .
        " -unsharp 0.2x0.6+1.0" .
        " -quality $QUALITY JPG:-";

header("Content-type: image/jpeg");
passthru($command, $retval);

and then in the html part <img src="foo.php">
  • 写回答

3条回答 默认 最新

  • dousi2029 2010-12-13 01:04
    关注

    If you don't need to keep the modified image then using passthru saves a disk write and a delete. Your app is probably not that speed sensitive though.

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题