Some help pls w/ command line text lables

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

Some help pls w/ command line text lables

Post by rocketshiptech »

I need to make a lot of these:

Image

That is:
1. make a box of a specific color (I'll have an rgb value) a 1 pixel boarder and rounded corners would be nice, but I'm not picky
2. make a thumbnail of another file (.png) 10 pixels smaller than the box and place it 5 pixels in from the left edge of the box
3. place a "text box" 5 pixels in from that, with words TBD, it needs to fill the space remaining, words should cut off it they don't fit
(but I can do all that pixel math before time)

I could really use for someone to show me an example command line that will do this.

FYI, i'll be doing this in a .COM IM implementation from VBA

(i thought i could do this myself, and was reading the instructions, but when i got "pengo" i thought "ok i need help")

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

Re: Some help pls w/ command line text lables

Post by snibgo »

That looks simple enough. I'd start by building it up the code, piece by piece. How far have you got already? Anything you don't understand? Or do you want someone to do it all for you?
snibgo's IM pages: im.snibgo.com
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: Some help pls w/ command line text lables

Post by rocketshiptech »

Well, the list of what I don't understand would be lengthy. I'm a VB coder who, up till now, has only used IM for one simple (although highly customized) file format conversion. I kinda out of my depth.

The number of options are bewildering. i don't know if the text should be a label or a caption, (and WTF is pengo??) and while I really do hate to be one of the "please-do-my-work-for-me" guys in a forum, I just need to see one clear example of this, I could take from there. Maybe there is an existing example I missed?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Some help pls w/ command line text lables

Post by snibgo »

I doubt that you need pango. "-annotate" may be best; see http://www.imagemagick.org/Usage/text/#annotate and the rest of that page.

You will use "-resize" to resize your png image, and probably "-border" to add borders. "-append" may also be useful. For the options generally, see http://www.imagemagick.org/script/comma ... ptions.php
snibgo's IM pages: im.snibgo.com
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: Some help pls w/ command line text lables

Post by rocketshiptech »

"annotate" that looks like what I want, more precicly the "practical examples" here:

http://www.imagemagick.org/Usage/annotating/#practical

Thanks!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Some help pls w/ command line text lables

Post by Bonzo »

One method:

Code: Select all

convert -size 350x160 xc:none -stroke black -strokewidth 1 -fill blue -draw "roundRectangle 1,1 348,158 10,10 " -fill none -draw "Rectangle 180,10 338,148 " ( input.jpg -thumbnail x140 -bordercolor black -border 1x1 ) -gravity west -geometry +5+0 -composite -fill black -font Arial -pointsize 20 -gravity northwest -annotate +200+20 "Rubblewebs" output.png
No idea how you would adapt it to VBA and the thumbnail image size will depend on the input image.

As snibgo hinted it may be better to create the two different halves then join them instead of the one large image I created in one go.

Should explain the workflow
1/ Create the canvas with a transparent background: convert -size 350x160 xc:none
2/ Draw the two rectangles: -stroke black -strokewidth 1 -fill blue -draw "roundRectangle 1,1 348,158 10,10 " -fill none -draw "Rectangle 180,10 338,148 "
3/ Resize the image ( stripping everything except the color profile ) and adding the border: ( input.jpg -thumbnail x140 -bordercolor black -border 1x1 )
4/ Putting the image over the background: -gravity west -geometry +5+0 -composite
5/ Writing the thext: -fill black -font Arial -pointsize 20 -gravity northwest -annotate +200+20 "Rubblewebs"
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: Some help pls w/ command line text lables

Post by rocketshiptech »

THANKS!

fyi- syntax in VB is the same as DOS.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Some help pls w/ command line text lables

Post by Bonzo »

fyi- syntax in VB is the same as DOS.
That's OK then as I ran the code above from the command prompt.

Obviously you will need to tweek the code to your requirements but it should give you a starting point.
rocketshiptech
Posts: 21
Joined: 2013-09-01T05:52:51-07:00
Authentication code: 6789

Re: Some help pls w/ command line text lables

Post by rocketshiptech »

That's exactly what I wanted. one clear example. Thanks.

What I'm actually thinking of doing now is making one large bitmap, with many of these little boxes on it, but I think you given me all the code I need for that,too.

Thanks again.
Post Reply