douzhao9608 2018-07-02 14:55
浏览 203

为什么imagemagick中的PNG图像要用readimage和writeimage花费很多时间?

I'm using Imagemagick version 7.0.5-4 to perform image processing operations like crop, resize etc with go-graphics library. I also manage a pool of magickwand objects.

Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib

The read time of image to MagickWand object as magickWand.ReadImage(<url>) in png images is very high compared that of jpg images. For images of size around 22kb, reading a jpg file takes around 300ms and that of png image takes around 1-2 minutes.

Edited:

When a single request is sent to server, the read operation takes around 20ms, but when on load of 100rps, it goes till 2-4 minutes. This trend is only in png images, not in jpg.

Any ideas on what can be done different in reading png files and how it can be made performant? Its fine to reduce the quality of images to around 60%. Tried options like SetImageDepth but it made no difference.

  • 写回答

1条回答 默认 最新

  • dongpaozhi5734 2018-07-03 06:50
    关注

    The compression quality parameter has a different effect and meaning when dealing with PNG files from when dealing with JPEG files.

    PNG compression is always lossless and the appearance is never affected by the quality. As I cannot see your images, I would suggest you either don't bother compressing since it will happen anyway, or that you use a quality of 75. If you tell me you are saving cartoons or line drawings, I might advise differently.

    Please have a read here and do some experiments yourself with the tradeoff between time and filesize.

    I have made you some plots to show the effect on time to compress and compressed size for different quality settings using two different kinds of images - cartoons and photos - so you can see the effect.

    Here is a cartoon:

    enter image description here

    Look at how the quality setting (0-100) affects time and size with JPEG output:

    enter image description here

    Now look what happens if you use those same quality settings (0-100) when generating PNG output:

    enter image description here


    Now let's look at compressing an iPhone photo to JPEG:

    enter image description here

    And when compressing an iPhone photo to a PNG:

    enter image description here


    Hopefully you can see that using one quality setting from your config file for both PNG and JPEG and with photos and cartoons/line drawings is not ideal.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起