Page 1 of 1

-limit option ignored when converting to webp

Posted: 2016-04-12T12:17:08-07:00
by naegelejd
My ImageMagick version (convert):

Code: Select all

Version: ImageMagick 6.9.3-2 Q16 x86_64 2016-01-22 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype fpx gslib jng jpeg lcms ltdl lzma pangocairo png ps tiff webp wmf x xml zlib
It appears convert does not respect the -limit options when converting images to webp format. I'm just using valgrind to get a rough idea of memory usage (and monitoring via htop):

I'm using this sample image: https://upload.wikimedia.org/wikipedia/ ... t_10MB.jpg

These are my default resource limits:

Code: Select all

Resource limits:
  Width: 214.7MP
  Height: 214.7MP
  Area: 2.0825GP
  Memory: 993MiB
  Map: 1.9395GiB
  Disk: unlimited
  File: 768
  Thread: 1
  Throttle: 0
  Time: unlimited
Usage without limits:

Code: Select all

convert -quality 1 Pizigani_1367_Chart_10MB.jpg jpg:chart.jpg
convert -quality 1 Pizigani_1367_Chart_10MB.jpg png:chart.png
convert -quality 1 Pizigani_1367_Chart_10MB.jpg webp:chart.webp
which allocate
  • 801,414,828 bytes
    583,358,754 bytes
    1,372,146,502 bytes
bytes, respectively.

Usage with limits:

Code: Select all

convert -limit memory 80MB -limit map 80MB -quality 1 Pizigani_1367_Chart_10MB.jpg jpg:chart.jpg
convert -limit memory 80MB -limit map 80MB -quality 1 Pizigani_1367_Chart_10MB.jpg png:chart.png
convert -limit memory 80MB -limit map 80MB -quality 1 Pizigani_1367_Chart_10MB.jpg webp:chart.webp
which allocate
  • 2,641,707 bytes
    2,967,726 bytes
    791,755,902 bytes
respectively.

My goal is to impose absolute limits on convert and I'm only interested in converting to webp. Is this possible? Thanks

Re: -limit option ignored when converting to webp

Posted: 2016-04-12T14:59:23-07:00
by magick
ImageMagick enforces limits for itself but not for any delegate programs or libraries. ImageMagick leverages the webp delegate library when reading or writing the WebP format. While most ImageMagick readers and writers read or write one scanline at a time (in memory or on disk), the WebP delegate program wants to process the entire image. If you are aware of a method to read or write one scanline at a time with the WebP delegate library, let us know. In the mean-time, when writing webp images, you can reduce memory usage of lossy encoding with -define webp:low-memory=true.

Re: -limit option ignored when converting to webp

Posted: 2016-04-13T12:16:43-07:00
by naegelejd
OK that makes sense, thanks and sorry for the noise. Unfortunately I'm not aware of any methods for reading/writing one scanline at a time with the webp lib. I'll work with the low-memory=true option in the mean-time.