bash: create black rectangles / squares using imagemagick

To create rectangles of a solid color with bash, following script comes in handy. Save it in a file, e.g. createBlackRect.sh and run it with

bash /path/to/script/createBlackRect.sh

Here the script

#!/bin/bash

# ============================================================================================
# creates several black square .png images
# ============================================================================================

for (( i=128; ${i}<=800; i++));  do
    for ((j=128; ${j}<=800; j++)); do
        convert -size ${i}x${j} xc:#000000 BlackSquare_${i}x${j}.png
    done
    echo Created File ${i} of 800
done

#000000 is the color black, to have another color, e.g. red use #990000. For more color information, see imagemagick color names.

 

blog_tags: 

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <img> <br> <p> <span>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Use [collapse] and [/collapse] to create collapsible text blocks. [collapse collapsed] or [collapsed] will start with the block closed.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Code snippets in <code>...</code> or <source>...</source> automatically will be pretty printed.
  • Use [collapse] and [/collapse] to create collapsible text blocks. [collapse collapsed] or [collapsed] will start with the block closed.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Target Image