-limit option ignored when converting to webp

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
naegelejd
Posts: 2
Joined: 2016-04-12T10:59:47-07:00
Authentication code: 1151

-limit option ignored when converting to webp

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -limit option ignored when converting to webp

Post 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.
naegelejd
Posts: 2
Joined: 2016-04-12T10:59:47-07:00
Authentication code: 1151

Re: -limit option ignored when converting to webp

Post 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.
Post Reply