utdev
utdev

Reputation: 4102

ImageMagick create image with 2 lines

I recently tried imagemagick and wanted to ask how I create an image (.bmp file) which looks like this:

enter image description here

My current code looks like this:

convert -size 720x480 xc:blue \ -fill white -stroke black -strokewidth 0 -draw "line 5,20 95,20" \ myImage.bmp

But it creates thisenter image description here

Upvotes: 1

Views: 1089

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207465

I would probably go with this:

convert xc:black[720x480\!] -size 100x5 \
   \( xc:lime xc:blue -append -write MPR:stripe \) -geometry +165+400 -composite \
  MPR:stripe -geometry +295+400 -composite \
  MPR:stripe -geometry +425+400 -composite result.png

The interesting part is the second line where I create a lime green rectangle and a blue one the same size underneath (-append) and save that in an MPR (Magick Persistent Register) called stripe, then I re-use that to make each subsequent stripe.

Or this:

convert -size 720x480 xc:black -strokewidth 5 \
  -stroke lime                                \
  -draw "line 165,400 265,400" -draw "line 295,400 395,400" -draw "line 425,400 525,400" \
  -stroke blue                                \
  -draw "line 165,405 265,405" -draw "line 295,405 395,405" -draw "line 425,405 525,405" myImage.bmp

enter image description here

Upvotes: 3

Bonzo
Bonzo

Reputation: 5299

You have some rubbish in your command but it has done what you asked it to - draw a black line on a blue background.

This should get you started:

convert -size 720x480 xc:black -strokewidth 5 -stroke green -fill none -draw "line 50,200 95,200" -stroke blue -draw "line 50,205 95,205" myImage.bmp

Upvotes: 0

Related Questions