<< Home

Thursday, April 17, 2008

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


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


Background


Final


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



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.

2 Comments:

Anonymous MotivatedTea said...

Yeesh! I'm amazed that Marvel is spending so much time trying to obfuscate things without even making an attempt to contact you. It's blindingly obvious that they know about your program and your blog (therefore they do have a way to contact you).
You'd think they could spend the effort writing a better viewer themselves so your program wouldn't be necessary.

2:45 PM

 
Blogger Derek said...

It's frustrating, but I'm sympathetic. If they make any official comment, they risk giving me publicity and/or causing a PR backlash from fans.

Also, they might need to meet certain subscription levels before justifying the expense of writing a better viewing program. Whatever they come up with would almost certainly have to be Windows and Mac desktop applications, and that's not a trivial project to develop/test/support.

I may add a watermarking feature so that a person's username is embedded in the final images. That might be enough to show enough good will on my part for Marvel to stop changing how their server works, at the very least.

3:45 PM

 

Post a Comment

<< Home