Home » Busy-Work, Drawing, projects, Python » Add comic bubbles to pictures with addcap.py.

Add comic bubbles to pictures with addcap.py.

I wrote addcap.py to be able to add comic bubbles and captions to photos.

get it on github.

Images have (x,y) pixel coordinates like quadrant 4 in the Cartesian plane. You don’t need to know that. The upper left corner is (0,0). Moving to the right increases x. Moving down increases y.

On an image with dimensions 800×600 the middle point is (400, 300).

Addcap will draw a caption bubble on your image but you have to tell it where. It needs a starting point, and for you to tell it which corner that point is. Addcap will always draw down and to the right. If you tell it the lower right corner coordinate(LOWER_RIGHT), then it will figure out where upper left is and draw from there.

You can pass all kinds of other options too. Check them out with -h.

python addcap.py -h
usage: addcap.py [-h] [-i IMG] [-sx STARTX] [-sy STARTY] [-tw TEXTWRAPWIDTH]
                 [-fs FONTSIZE] [-cc CHARACTERCOUNT] [-sc STARTINGCORNER]
                 [-ca CALLOUTARROW] [-f FOLDER] [-o OUTFILE] [-qf QUOTEFILE]
                 [-q QUOTE [QUOTE ...]]

optional arguments:
  -h, --help            show this help message and exit
  -i IMG, --img IMG     Image to add a caption to.
  -sx STARTX, --startX STARTX
                        Starting X Coordinate for caption bubble.
  -sy STARTY, --startY STARTY
                        Starting Y Coordinate for caption bubble.
  -tw TEXTWRAPWIDTH, --textWrapWidth TEXTWRAPWIDTH
                        How many characters before a line wrap in the bubble?
  -fs FONTSIZE, --fontSize FONTSIZE
                        Font size
  -cc CHARACTERCOUNT, --characterCount CHARACTERCOUNT
                        Character count. limited to 140 by default.
  -sc STARTINGCORNER, --startingCorner STARTINGCORNER
                        The corner that your start coordinates create. Values
                        are Values are UPPER_LEFT, LOWER_LEFT, LOWER_RIGHT,
                        UPPER_RIGHT
  -ca CALLOUTARROW, --calloutArrow CALLOUTARROW
                        Which call out arrow do you want, starting at
                        11oclock, going counter clockwise. Just put the
                        number, like 6
  -f FOLDER, --folder FOLDER
                        If defined, create a folder and store addcap images
                        there. Otherwise defaults to current folder.
  -o OUTFILE, --outfile OUTFILE
                        The outfile prefix name. Will append a number and JPG
                        to the end.
  -qf QUOTEFILE, --quoteFile QUOTEFILE
                        A file with 1 quote per line. Quotes should not exceed
                        140 characters.
  -q QUOTE [QUOTE ...], --quote QUOTE [QUOTE ...]
                        One or more quotes in the form "This is a quote.",
                        "This is another quote", "This is yet another quote".
                        Individual quotes should not exceed 140 characters.

If you run demo.sh, then addcap will create a demo folder for you and fill it up with examples.

 

ATTRIBUTIONS!

All images pulled from FLICKR searching on ‘bad taxidermy’ where the CC flag was set to yes.
(C)Attribution license
(C)Attribution license
(C)Attribution license
pugnax” by  istolethetv
(C)Attribution license
bad taxidermy”  by avidd
(C)Attribution License
crazy taxidermy” by Ed Schipul
(C)Attribution Share-Alike License