annotate not working w/ COM Object IM from VB

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
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

annotate not working w/ COM Object IM from VB

Post by rocketshiptech »

Hi guys:

In the COM Object version if IM, the Convert() function takes ALL the parameters as strings (in quotes, unless your calling a variable you dimensioned as a string), separated by commas. like this:

this works:
destFilePath = Me.ProjRootFolder & "\test.png"
txtConvertResult = objMagImage.convert("png:", "-size", "700x500", "xc:none", "-stroke", "black", "-strokewidth", "1", "-fill", "#555555", "-draw", "roundRectangle 1,1 348,158 10,10 " destFilePath)

notice that "roundRectangle" which requires quotes in other builds, does NOT need quotes in COM, it already is a string.


this does NOT work:
TLUnitTxt = "Now is the time for all good men"
txtConvertResult = objMagImage.convert("png:", "-size", "700x500", "xc:gray", "-fill", "black", "-font", "Arial", "-pointsize", "20", "-annotate", "+10,+10", TLUnitTxt, destFilePath)

IM doesn't error, it makes a picture, but there are no words on it.

now in examples I've seen -annotote uses single quotes around the text. DOS command line examples I've seen use double quotes. I'm assuming that is problem.

I've tried EVERY COMBINATION of single quotes, double quotes, double double quotes, triple double quotes, even "& Chr(34) &" (which is an old VB trick for quote marks within a string)

I'm stumped. Has any anyone ever gotten -annotate to work from a COM object?

do i need a -draw in there somewhere?

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

Re: annotate not working w/ COM Object IM from VB

Post by snibgo »

I don't use COM, so can't advise about that.

"-annotate" (like most options) doesn't need the string to be in quotes unless the string contains spaces. For your initial tests, you might remove the spaces.

This command works from the command prompt...

Code: Select all

convert -size 700x500 xc:Gray -fill Black -font Arial -pointsize 20 -annotate +10+10 Nosisthetimeforallgoodmen t.png
... making black text crammed into top-left on a gray background.

Maybe COM has a problem with "-font Arial". Try removing it, or providing the full filename to the ttf font file.
snibgo's IM pages: im.snibgo.com
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: annotate not working w/ COM Object IM from VB

Post by rocketshiptech »

thanks but I had tries both those things, (and just did again). no go.

guess i need some one who has used the COM DLL
Thanks anyway
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: annotate not working w/ COM Object IM from VB

Post by dlemstra »

If your program is written in .NET you could consider switching to Magick.NET.

edit: fixed link
Last edited by dlemstra on 2013-09-03T06:28:05-07:00, edited 1 time in total.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: annotate not working w/ COM Object IM from VB

Post by rocketshiptech »

1. that link is dead. (although I did find your page from your sig)
2. not .Net

it's just going to be a syntax issue.

(Am I the only guy out there using the COM object?)
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: annotate not working w/ COM Object IM from VB

Post by dlemstra »

Did you try: "+10,+10 " & TLUnitTxt?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: annotate not working w/ COM Object IM from VB

Post by rocketshiptech »

Well, i did just now, that cause IM to error out and not generate a file. Just like it does if you leave the quotes out or combine any other 2 or more parameters into one string.
(at least I starting to learn its behavior that well.)
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: annotate not working w/ COM Object IM from VB

Post by rocketshiptech »

Nevermind.... (does anyone remember Emily Litella?)

I reinstalled IM and it works, something wrong with my install, (or my build of the Object)

thanks guys
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: annotate not working w/ COM Object IM from VB

Post by dlemstra »

Would you mind posting the parameters that worked? So other users of the COM Object will know how it should work.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply