Sep 16 2009

ComicBake 0.0 sneaks out the door!

Published by Dougal at 10:16 pm under Culture, Programming

It’s not what any sensible person would call usable, but I’m now announcing the appearance of ComicBake, which is what I’m calling my app for creating web comics.

ComicBake is a CLI tool for making web comics. I shall demonstrate a quick example to let you understand. (This example also appears in the source repository so you can actually recreate it too.)

Example Comic: The Conversation

The first thing you need is an image, preferably with characters who can do some talking. I’ve chosen this image from Flickr of two people having a conversation. I don’t know who they are but it’s a nice photo and it’s suitably licensed so I can manipulate it as I please.

Then you need a script file which tells the compiler all about the action in the scene.

-- A Conversation
-- A Series of Examples
-- 05 September 2009
-- Dougal Stanton
 
-- Photo CC-licenced from:
-- http://www.flickr.com/photos/clairity/154640125/
 
Scene 1. <scenes/conversation.png>
 
Woman: This is just a simple demonstration.
 
Man: Is that because it breaks
     with anything longer?

Ignore the first half-dozen lines as they’re just commentary (though I plan to use them in the future). The important points to note are:

  1. The scene description (including file path to image)
  2. The dialogue.

There are two characters here, and we can easily tell who is who but the computer needs more help. Next up is an image map, which associates names with co-ordinates:

<img src="conversation.png" width="500" height="306" border="0" usemap="#map" />
 
<map name="map">
<!-- #$-:Image map file created by GIMP Image Map plug-in -->
<!-- #$-:GIMP Image Map plug-in by Maurits Rijk -->
<!-- #$-:Please do not edit lines starting with "#$" -->
<!-- #$VERSION:2.3 -->
<!-- #$AUTHOR:Dougal Stanton -->
<area shape="rect" coords="46,29,108,88" href="woman" />
<area shape="rect" coords="426,9,494,73" href="man" />
</map>

This is just the raw file produced by The GIMP when you use its HTML image map feature. The link name for each area (href="...") doubles as the character name. Thankfully you’ll only ever have to do this once for any given image.

Pull all that together and you get:

Getting it, Using it

The code is in the usual place:

darcs get --partial http://www.dougalstanton.net/code/comicbake

To build it use the cabal-install tool. This sets the default install to be your home dir rather than system-wide:

cabal configure --prefix=$HOME --user
cabal build

That should get all dependencies except for gtk2hs+cairo, which is a real pain and something I’m planning to abandon before long. The best bet is to see whether your distro has a package for it…

Running it is simple. It only take one argument, the script file. So if you want to execute the example script:

./comicbake example/conversation.script

This will save a frame1.png into the current working directory.

Bugs

I’m still in active hacking at the moment — not even really alpha as it’s a bit of a mess. But I figured that if I didn’t release something now I would forget about it and it would disappear eventually. Which would be a shame because I think it’s quite a neat idea with some interesting potential.

  • The most obvious problem is that if you give it anything more than a couple of speech bubbles to place it can’t find space for them and bails out. The error message you see will be: Prelude.head: empty list. This needs sorted.

  • The Diagrams package I’m using is not as suited to the job as I’d hoped, for two reasons. One is that I can’t know how big my speech bubbles will be before I place them, so I’m using conservative guesswork which has so far been quite successful. But it’s not a solution.

  • The other problem is that accurate placement of the resulting objects is something that the Diagrams package doesn’t do very well. It doesn’t think in terms of absolute pixel sizes, so things tend to grow and shrink depending on the space needed.

  • There are a lot of similar-looking tuples littering the code which should be more strictly separated. It would make the code easier to read and reason about, and the type checker would help me more.

The first thing I need to do is sort out my bubble placement algorithm which is clearly not as effective as I’d thought. Then I’ll be replacing Diagrams with GD, I think.

After that there are “to do” items which may happen if it falls easily into my schedule.

  • Neaten up the script parser some more to allow multi-paragraph speeches and some unnamed characters to represent narration or offstage voices.

  • Make the script preamble more explicit. At the moment I don’t use the author’s name or date or any of that stuff yet but it’s there for the future. It would be better if they existed as named fields rather than just being free-form.

  • Write a proper parser for the image maps. I’m currently depending on Neil Mitchell’s TagSoup library for simple HTML parsing. But as I’m already using Parsec elsewhere it seems foolish to depend on them both. Why take two parser frameworks into the shower?

  • Proper command line support. Multiple arguments, let the user choose filenames, maybe some help or useful error messages.

Later on there are some things which I would really like to do. These are actual features which are pretty neat:

  • Stitch the various scenes together in some formation, eg 2x2 or 3x1, so they can be published as a single unit. The author name and comic strip title obviously become more important at this point as it brings all the images together into a story.

  • An alternative that is also pretty good is converting the same story into a flickbook comic, using anim gifs or similar to show the progress.

If anyone has any good ideas just say so! Also if you want me to actually explain how it works I’ll make a detailed post later. Hopefully when it’s closer to working! :-)

8 responses so far

8 Responses to “ComicBake 0.0 sneaks out the door!”

  1. Nickon 17 Sep 2009 at 7:23 am

    First of all, you’re using Darcs I see. This interests me, since I basically discounted it when doing a recent investigation into DVCS. I’m now tasked with writing a white paper in this very subject for my company’s consideration. Any thoughts?

    Secondly, I take it you’re doing it in Haskell?

    Thirdly, unless the standard comic script layout differs greatly from the standard screenplay layout, you’re format doesn’t follow it.

    And lastly, I think your image map needs to give more indication of where the characters mouths are. Also, have you considered using graphviz (or something similar) as a component in your layout engine?

  2. Dougalon 17 Sep 2009 at 8:21 am

    Erm, well I’ve used Darcs for a few years now. It’s by far the nicest version control system I’ve used. It really depends on your requirements as with all things. Currently GHC use it but want to move away from it because it doesn’t cope so well with very large projects. On the other hand I don’t think they have moved away from it yet because the major problems have been fixed or ameliorated in some way.

    Yes, I am. You gotta problem with that? :-)

    As far as I understand there is no “standard comic script layout”. I just made it up. But I modelled it on theatrical scripts which I’ve read plenty of, and adapted for the purpose.

    I think you’d be surprised how little it matters. Right now the bubbles don’t end up where I want them to go, and the tails don’t really take account of where the characters’ heads are. These two problems obviously interact to make things appear worse than they are (ie, the tails point approximately towards where the characters’ heads might be if the bubbles ended up where they should be). But ultimately I don’t want to make people pick out every single feature of interest on the image.

    If you’re volunteering to suggest a face-recognition algorithm, of course, I’m all ears…

    I did consider something like Graphviz originally but I ultimately want more control than that would afford. It’s certainly an interesting approach to take, and I was thinking about it on my walk to work this morning, but Graphviz doesn’t even imply an ordering on its nodes. The elements of conversation don’t commute. :-)

    I think my best approach is to use the GD bindings for image stuff, to get a more faithful idea of where the bubbles are trying to appear.

  3. Helenon 17 Sep 2009 at 11:12 am

    so this is what you get up to when I go to bed at half past ten!

  4. Dougalon 17 Sep 2009 at 11:41 am

    Guilty as charged!

  5. Mikeachimon 17 Sep 2009 at 5:10 pm

    What fun.

    All you need now is a fancy front end - rectangles with rounded-off corners, different shades of blue, popping noises when things open & close - and this will go nuts online.

    Seriously. As soon as the average Mashable reader can operate it (and I know that’s a tall order and will involve levels of hand-holding beyond the wildest dreams of any prom night) you will start doing very well indeed.

    Scarily well, perhaps.

  6. Kenon 24 Sep 2009 at 9:50 pm

    Groovy!

    I wish I understood it. I have a program which came with my iMac to do it all for me, but that’s not the point, is it?

  7. Dougalon 25 Sep 2009 at 10:20 am

    I have been rewriting the graphics part to use a different graphics library and will have more details soon, and maybe a more interesting explanation. Stay tuned!

  8. Coinneachon 25 Sep 2009 at 3:12 pm

    Where the persons mouth is situated is not important. The problem is where there are two characters in the frame at the same time and the order in which they speak can create a problem. Like where you read the answer before the question! The problem exists in normal drawn cartoons. Perhaps when the second person speaks this would be indicated by an italicised font?