Search
Blog Index
Recent Ponoko posts
Recent Thingiverse entries
Recent tweets
Navigation
« Digital Comic Downloader discontinued | Main | More about the comic download tool »
Thursday
Apr172008

Image manipulation progress

Some progress on the comic downloader.

I've got programmatic image manipulation largely done. The process is basically this: Render the SWF text layer at twice the size of the JPG background layer, then make it transparent and scale down to fit. (That makes the output quality a bit better.)

To test things out I used the command-line ImageMagick tools:

convert -fuzz 115 foreground.png -transparent "#ff00ff" -resize 1000x1500 foreground-transparent.png
composite foreground-transparent.png background.jpg final.png

Then I added the MagickNet DLL (a .NET wrapper for the ImageMagick libraries) to my project and rewrote the steps in C#:

MagickNet.Magick.Init();
MagickNet.Image imgForeground = new MagickNet.Image(Application.StartupPath + @"\foreground.png");
imgForeground.ColorFuzz = 115;
MagickNet.Color imgColour = new MagickNet.Color(255, 0, 255);
imgForeground.Transparent(imgColour);
Size imgSize = new System.Drawing.Size(1000, 1500);
imgForeground.Resize(imgSize);
imgForeground.Write(Application.StartupPath + @"\foreground-transparent.png");
MagickNet.Image imgBackground = new MagickNet.Image(Application.StartupPath + @"\background.jpg");
MagickNet.Image imgForegroundTransparent = new MagickNet.Image(Application.StartupPath + @"\foreground-transparent.png");
imgBackground.Composite(imgForegroundTransparent,0,0,CompositeOperator.AtopCompositeOp);
imgBackground.Write(Application.StartupPath + @"\final.png");
MagickNet.Magick.Term();

Much to my surprise, it worked! Here's what the input and output images look like:

Foreground

image

Transparent foreground (note: some browsers can't render transparent PNG files correctly)

foreground-transparent

Background

image

Final

image

It's not perfect, because if you zoom in 1200% you can see some purple left on the edges of the speech balloons:

image

However the goal is not in creating pristine archive copies for hoarding, but temporary copies for convenient reading. So it's fine. :)

Next up is to see if I can replicate the full MDCU login process. The current method involves: logging in normally, opening a comic, then viewing the HTML source of the page to get the session id and issue id, then pasting those into my program. Not terribly convenient.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>