Home > Application Develeopment > Image manipulation progress

Image manipulation progress

April 17th, 2008

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 1000×1500 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.

techknight Application Develeopment

  1. No comments yet.
  1. No trackbacks yet.