convert: Non-conforming drawing primitive definition `image’.

ImageMagick is a nice collection of image manipulation routines. It’s free, and somehow it should be. It’s powerful, but also works and fails in miracolous ways. It just wasted twenty minutes. My Minutes. It would have taken the person writing the code probably 2 to make the error message a little bit more meaningful. To cut to the chase: When ImageMagick tells you:

convert: Non-conforming drawing primitive definition `image'.

then it’s probably only telling you that it can not open the image you like to draw. In plain command line that would be:

convert -size 700x500 xc:black -draw 'image Over 0,0 400,300 directory/image.jpg' output.jpg

This will fail. It turns out that ImageMagick needs to have a local file NOT with a path component. To sucessfully do what you wanted to do you would have to:

cd directory ; convert -size 700x500 xc:black -draw 'image Over 0,0 400,300 image.jpg' ../output.jpg ; cd ..

Possible, sure. But a hint like “can not open file directory/image.jpg” would have been nice. The best would be path support as suspected. It works everywhere else.

Of course it turned out that this is supposed to be a feature. In the end things start to work when you quote the filename, like in:

convert -size 700x500 xc:black -draw 'image Over 0,0 400,300 "directory/image.jpg"' output.jpg

Otherwise a filename like 123_3×4.jpg would also get you in trouble.

8 Responses to “convert: Non-conforming drawing primitive definition `image’.”

  1. Kyle Says:

    Your twenty minutes saved me 10.

  2. Joe Says:

    Thank you so much! I’ve wasted much more than 20 - but suspect it would have kept me up all night.

  3. Robert Says:

    Great explanation Andreas, thanks !!

  4. Lasse Says:

    Well your 20 just caused me another 5… Not that I’m holding you as responsible!
    but I’ve just set the permissions for the directory to 777 but i doesn’t work! I’ve even tried with other directories. But it doesn’t help. I’ll be back with a solution as soon as I fine one (if i remember).

    - Lasse

  5. Chris Wilson Says:

    I finally discovered that ImageMagick (and therefore RMagick/Magick) does not work with font file paths that start with a slash (i.e. absolute paths on Unix). It does work with relative paths though, so I had to convert all my absolute paths to relative, like this:

    font_path = File.join(RAILS_ROOT, “lib”, “fonts”, “cursif”, “Cursif.ttf”)

    if (font_path[0,1] == ‘/’)
    font_path =

    and then it works :-)

  6. Oscar Says:

    I am sooo glad that Google brought me to your site. After installing a new server my script stopped working…and this was the solution!

  7. Julien Desrosiers Says:

    @Chris Wilson : thanks so much. This was exactly my problem : the font was not loading correctly because i was pointing to it via an absolute path (that begins with a /).

    Thanks for this post.

  8. fraff Says:

    enclosing path with quote do the trick

    convert -size 700×500 xc:black -draw “image Over 0,0 400,300 ‘/path/to/file.jpg’” output.jpg

    will work.

Leave a Reply

You must be logged in to post a comment.