Non-conforming drawing primitive definition error

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ertank
Posts: 13
Joined: 2018-06-19T08:27:55-07:00
Authentication code: 1152

Non-conforming drawing primitive definition error

Post by ertank »

Hello,

I am using ImageMagick 7.0.8-2 Q16 x64 2018-06-18 on Widnows 10 64Bit.

I want to merge two image files of same size.

For command line below:

Code: Select all

magick "C:\Users\Ertan\Desktop\backgrounds\pngbackground1.png" -draw "image over 0,0 0,0 'E:\Freelancer\usa\textfit\Win64\Debug\20180713_001745_Arial\the_king_of_jesus.png'" "E:\Freelancer\usa\textfit\Win64\Debug\20180713_001745_Arial\the_king_of_jesus.png"
I receive following error:

Code: Select all

magick: non-conforming drawing primitive definition `image' @ error/draw.c/DrawImage/4287
I am sure that image files are there in directories in the command line. I just fail to see how I should be fixing this. I tried to change single quotes to double quotes of the middle filename in above command, but that leads to a different error.

If I move second image in same directory as magick.exe and use following command:

Code: Select all

magick "C:\Users\Ertan\Desktop\backgrounds\pngbackground1.png" -draw "image over 0,0 0,0 'the_king_of_jesus.png'" "the_king_of_jesus.png"
I get no no errors displayed. Resulting image is what I would like to have as final.

Image files can be reached from below links:
https://imgur.com/9dMsOs0
https://imgur.com/XjGymZn (text is black and web site uses black as background. Image is not visible, but it is there for sure).

Any help is appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Non-conforming drawing primitive definition error

Post by fmw42 »

Your background image (at least the one uploaded) is jpg not png. That might be the issue. Also try removing the paths and have both images in the same directory from which you use the magick command.

The following works fine for me on IM 7.0.8.6 Q16 Mac OSX Sierra.

Code: Select all

magick background.jpg -draw "image over 0,0 0,0 'overlay.png'" result.png
Alternately, you could just use -composite

Code: Select all

magick background.jpg overlay.png -composite result.png
You can then use -gravity and -geometry for positioning.

See
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/layers/#convert
ertank
Posts: 13
Joined: 2018-06-19T08:27:55-07:00
Authentication code: 1152

Re: Non-conforming drawing primitive definition error

Post by ertank »

My background image is transparent PNG for sure. It is -as you guessed- that imgur.com website converted it to JPG.

This command line is generated by an application. I probably not able to change it to have both images in the same directory. Will it help if I post that in bug section? Maybe developers will have a look at that situation.

I have to use different combinations of background images (bmp, jpg, png-non transparent, png-transparent, etc.) and foreground is always a png-transparent image. If I use a non-transparent image as background, it is fine that final image will loose transparency.

All images I need to merge will have same size in pixels. I do not need any positioning. It is "draw" command line parameter that I know and used.

I will try "composite" command line parameter and see if it helps.

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

Re: Non-conforming drawing primitive definition error

Post by fmw42 »

It should not matter what format you have for the input, so long as it does not have multiple pages/frames/layers.

My guess is that your code is not filling in the proper names or arguments if it is programmed to use variables.

Using -composite is simpler than -draw. So I would try that. I would not suggest you use composite ..., but use convert .... -composite, since it is newer and more flexible.

Perhaps there was a bug in your version of Imagemagick on Windows. But I tried your command using IM 7.0.8.6 and it worked fine for me on Mac OSX Sierra.
ertank
Posts: 13
Joined: 2018-06-19T08:27:55-07:00
Authentication code: 1152

Re: Non-conforming drawing primitive definition error

Post by ertank »

Application generated command lines what I wrote in initial post in this thread. I doubt that it is my generated command line is the problem.

On the other hand, I tested with -composite and it works nicely using a command line below:

Code: Select all

magick.exe "C:\Users\Ertan\Desktop\backgrounds\pngbackground1.png" "E:\Freelancer\usa\textfit\Win64\Debug\20180713_014458_Arial\the_king_of_jesus.png" -composite "E:\Freelancer\usa\textfit\Win64\Debug\20180713_014458_Arial\the_king_of_jesus.png"
I could not find basic use example of convert ... -composite in below link.
https://www.imagemagick.org/Usage/layers/#convert

What I came up is following command working in my trials:

Code: Select all

magick.exe convert "C:\Users\Ertan\Desktop\backgrounds\pngbackground1.png" "E:\Freelancer\usa\textfit\Win64\Debug\20180713_014458_Arial\the_king_of_jesus.png" -composite "E:\Freelancer\usa\textfit\Win64\Debug\20180713_014458_Arial\the_king_of_jesus.png"
I see very little difference than using -composite directly. As it is newer, I will use that second command line structure.

Thanks.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Non-conforming drawing primitive definition error

Post by snibgo »

Tests with v7.0.7-28 on Windows 8.1 suggest that the problem is with "C:" in the filename. Within a "-draw", IM v6 correctly interprets this to mean drive C. But IM v7 gets confused.

V6:

Code: Select all

f:\web\im>%IM%convert toes.png -draw "image over 0,0 0,0 'F:\web\im\r.png'" x.png
This gives no error message, and correct processing.

However, v7 gives:

Code: Select all

f:\web\im>%IMG7%magick toes.png -draw "image over 0,0 0,0 'F:\web\im\r.png'" x.png
.png': Invalid argument @ error/blob.c/OpenBlob/3375.
So it seems to be a v7 bug.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Non-conforming drawing primitive definition error

Post by fmw42 »

To the OP, your first usage is the correct one.

When using IM 7, use magick in place of convert, not both together. Only combine them for commands other than convert, such as magick identify or magick mogrify, etc. Your second example with both is likely using IM 6 and not IM 7.
ertank
Posts: 13
Joined: 2018-06-19T08:27:55-07:00
Authentication code: 1152

Re: Non-conforming drawing primitive definition error

Post by ertank »

Thank you for clarifying.
Post Reply