dtgsl60240 2009-07-15 00:36
浏览 54
已采纳

Php Imageresize Performance

I'm working on an image resize script for php, and had a few questions..

Currently I'm pulling an external URL as the image, and don't really want to store the new image that is going to be re-sized on my server. Here is what I'm trying to do:

Have the script resize the image, than encode it the resized image in base64 on the fly. Now what I'm wondering is, would this be heavy on performance both doing the encode, and serving up the image with base64 rather than just the url? or would it be better to store the image rather than to store the base64 code for it?

  • 写回答

1条回答 默认 最新

  • dongroufan6846 2009-07-15 00:47
    关注

    Why are you encoding the resized image? Why not just output it directly. You don't need to save it to a file.

    Some relevant lines from php function page:

    // Content type
    header('Content-type: image/jpeg');
    
    // Resize
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    
    // Output
    imagejpeg($thumb);
    

    To include it in the page you would do something like:

    <img src="resizer.php?url=[encoded url here]" />
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置