convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
BigNoub
Posts: 33
Joined: 2015-12-29T14:49:52-07:00
Authentication code: 1151

convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.

Post by BigNoub » 2019-01-07T04:46:05-07:00

I'm using Imagemagick v 7.0.8-14 on Ubuntu 16.04

I'm using Fred's script dominantcolor to find the dominantcolor in an image. http://www.fmwconcepts.com/imagemagick/ ... /index.php

The script works fine on many images, but on some images it sends back the error

Code: Select all

convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.
and returns the color #FFFFFF

As far as I can tell, these images have nothing particular: they are, just like the others, 4000x2664 jpg files of about 2MB.

I don't think I have memory limits on my system, everything is commented in policy.xml and convert -list resource gives

Code: Select all

Resource limits:
  Width: 107.374MP
  Height: 107.374MP
  List length: -1
  Area: 10.3409GP
  Memory: 4.81535GiB
  Map: 9.63071GiB
  Disk: unlimited
  File: 786432
  Thread: 2
  Throttle: 0
  Time: unlimited
Here is an example of a file that is causing problems (here https://drive.google.com/file/d/1RiXQLk ... sp=sharing for uncompressed version):

Image

BigNoub
Posts: 33
Joined: 2015-12-29T14:49:52-07:00
Authentication code: 1151

Re: convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.

Post by BigNoub » 2019-01-07T07:27:08-07:00

I just tried with the same image resized to a smaller resolution (1000x666) and got the same error message.

I just found out that this problem happens only when I use the -m 5 and -m 6 options of the script. So it might not be a problem with Imagemagick but a problem with the script.

User avatar
fmw42
Posts: 25404
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.

Post by fmw42 » 2019-01-07T12:19:22-07:00

What was your exact command line? (What other arguments did you use?)

BigNoub
Posts: 33
Joined: 2015-12-29T14:49:52-07:00
Authentication code: 1151

Re: convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.

Post by BigNoub » 2019-01-07T12:23:37-07:00

fmw42 wrote:
2019-01-07T12:19:22-07:00
What was your exact command line? (What other arguments did you use?)
just that ./dominantcolor.sh -m 6 file.jpg

User avatar
fmw42
Posts: 25404
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert: memory allocation failed SparseColorOption @ error/mogrify.c/SparseColorOption/552.

Post by fmw42 » 2019-01-07T12:49:28-07:00

The problem is occurring because the processing is creating a totally transparent image for which sparse-color is failing to find any values. The solution is to increase the -f fuzz value until it can find some opaque colors to report.

Post Reply