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.
October 5th, 2007 at 10:38 am
Your twenty minutes saved me 10.
February 1st, 2008 at 8:09 pm
Thank you so much! I’ve wasted much more than 20 - but suspect it would have kept me up all night.
March 22nd, 2008 at 5:53 am
Great explanation Andreas, thanks !!
April 9th, 2008 at 7:21 pm
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
September 27th, 2008 at 2:21 pm
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 = Pathname.new(font_path).relative_path_from(Pathname.pwd)
end
and then it works
February 3rd, 2009 at 1:07 pm
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!
August 23rd, 2010 at 7:51 am
@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.
August 23rd, 2010 at 8:43 am
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.