dongxiangchan0743 2014-01-13 22:04
浏览 161
已采纳

通过PHP使用ImageMagick创建一个大型精灵消耗100%的CPU

So I've this:

exec("cd $upload_directory && convert \\( +append -limit memory 1 -limit map 1 *.jpg \\) -strip -trim -interlace Plane -quality 60 output.jpg

The workflow is:

  • User uploads *.zip file, containing about 30 pictures 2048x1152 each
  • Application unzips zip file
  • Application takes the pictures and makes a large sprite out of all of them
  • Application then redirects to a different page for processing.

Now the problems is with making the large sprite. It consumes 100% CPU (according to top on the server), it fails when there are many images. Also the process outputs Killed without any further error message.

Now, I'm sure I can solve this by throwing more muscle on the server, but I'm having the feeling that the one I have isn't the most efficient.

What can I try to mitigate the problem?

  • 写回答

1条回答 默认 最新

  • dongzhao4036 2014-01-20 19:18
    关注

    You kind-of answered your own question. You are doing something really intensive. The expected outcome is that CPU usage will shoot-up. Unzipping takes memory and cpu. Creating massive images takes IO, CPU, and Memory. If you ever used Photoshop, youll notice that your systems memory and cpu always shoots-up. Dealing with images is no simple task.

    If you want to handle large images using the current method, then you need a stronger server. There is no magic parameter that will make the process use less memory. If you have a 32MB image, its going to take a lot of memory to read it before you can even try to reduce its size.

    Hope that helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型