Skip to content

Instantly share code, notes, and snippets.

@blooalien
Last active November 8, 2020 11:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save blooalien/3668313 to your computer and use it in GitHub Desktop.
Save blooalien/3668313 to your computer and use it in GitHub Desktop.
A simple gimp plugin to easily create cartoon speech bubbles.

speechbubble.py

A simple GIMP plugin to easily create cartoon speech bubbles using arbitrary selection shapes.


License

  • Public Domain - This script is entirely too simple for me to care how it's used. Just enjoy it...

Installation

(Ensure that you have gimp-python installed if you wish to use Python based GIMP plug-ins.)

For versions of GIMP prior to v2.10, simply copy or link this script into your "$HOME/.gimp-2.x/plug-ins/" folder, mark it as executable, and you should be good to go... If you are on GIMP v2.10 (or later), this directory has changed from earlier versions. The new location for plug-ins is now "$HOME/.config/GIMP/2.10/plug-ins/" and this script should be placed there instead.


Usage

You may not want to alter your original image directly while using this plug-in, so be sure to create a separate layer above the image you're working with, and ensure that's the layer you're actually editing in order to protect the main image from unexpected changes.

(Chances are likely that you already knew this, but I mention it here just in case you're new to image editing.)

Create a selection in the size and shape of the intended speech bubble, then look in the "Filters" menu under "Render". If all went well with the installation, there should be a menu entry labeled "Speech Bubble". Choosing that will open a dialog asking for a "Line Stroke Size". This is the number of pixels thick that the outline of the resulting speech bubble will be. The rendered speech bubble should use the foreground color for the outline, and the background color to render the background of the speech bubble.


The attached file CoderCatExample.jpg shows the result of creating an irregular "thought bubble" type shape with some antialiasing and feathering applied to the selection to soften the edges. This plugin was then run with black foreground and white background, and we get a nice soft-edged cloudy thought bubble. Sharper edged selection shapes should result in a nice dark solid outline around the resulting bubble instead of this fuzzy look.

That's about it. Can't think of anything else right now. Enjoy...

#!/usr/bin/env python
# Title: Simple Speech Bubble
# Author: Bloo Alien <https://github.com/blooalien>
# License: Public Domain <http://creativecommons.org/publicdomain/zero/1.0/>
from gimpfu import *
def speechbubble(image, drawable, radius):
gimp.context_push()
image.undo_group_start()
pdb.gimp_edit_fill(drawable, FOREGROUND_FILL)
pdb.gimp_selection_shrink(image, radius)
pdb.gimp_edit_fill(drawable, BACKGROUND_FILL)
image.undo_group_end()
gimp.context_pop()
register(
"speech_bubble",
"Cartoon Speech Bubble",
"Add a cartoon speech bubble using the current selection.",
"Bloo Alien",
"Public Domain",
"2019",
"<Image>/Filters/Render/Speech Bubble...",
"*",
[
(PF_SPINNER, 'radius', 'Line Stroke Size', 2, (1,6,1))
],
[],
speechbubble,
)
main()
@witchpou
Copy link

Providing a screenshot would be really great.

@pthurmond
Copy link

This isn't working in GIMP 2.10. When I do it, I just see an empty white square overlayed on the image.

@blooalien
Copy link
Author

blooalien commented Dec 17, 2019

Providing a screenshot would be really great.

Sorry. I somehow never got the notification about your comment. I've added an example image showing the result of using this code. I'll add some screenshots when I have time, but hopefully the updates to this gist should help understand what's going on and how to use it.

This isn't working in GIMP 2.10. When I do it, I just see an empty white square overlaid on the image.

This was created in a hurry for a friend who was making a web comic a couple years back, so I haven't actually touched this code in ages, but I'll have a look and see what I can do about it...

Edit: I've just done a bit of testing and made appropriate changes to this gist to reflect my current findings. The example image attached was created with the exact Python code attached above, so I know for a fact that it does indeed now work with GIMP 2.10 (which I just installed today from PPA to upgrade from the GIMP 2.8 that I was using before.)

@micksulley
Copy link

I cannot get this to work. Running Mint20, the repository install is GIMP 2.10.18, i have also install AppImage which is 2.10.21 I have downloaded speechbubble.py and added it to hte plug-in directory for both but neither work. Research suggests it is because gimp-python is missing, and this is because that is python2 which is deprecated and no longer included in Mint. Is there any proper solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment