Blog

Intelligent image resize

There are times when you need a certain resolution in an image (like if you want to use it as a desktop wallpaper), but all you have is a small version – which means if you try and enlarge it, you get either a blurred or pixellated version.

There’s actually another way, which doesn’t seem to have caught on yet, probably because it’s a bit tricky still. You can trace the image, making a vector version, then resize it to anything you like. Provided you’re starting with enough resolution, the effects can be quite good.

It’s all thanks to the genius of Peter Selinger’s Potrace library. It’s built into Inkscape, which runs on most platforms.

Start up Inkscape (If you’re running Leopard, I think you have to start up X11 first, manually), and open the image you want to enlarge. Select the image, then go Path, Trace Bitmap.

200802021841

Configure it to use colours, not smooth, and choose a good number of scans (the more, the more colours and better representation of the original image)

200802021842

Click OK and wait while it does it (this may take a little while). Once it’s done it’ll tell you in the status bar, and the ‘OK’ button will re-enable. Close the ‘Trace Bitmap’ dialog (with the window controls at the top, not by clicking ‘OK’, which will just do it again).

Now, to save the result, click File, Export Bitmap, choose ‘Selection’, and choose whatever size you want to export as.

200802021844

Done!

If you’re adventurous, you can also export as postscript or PDF, by going File, Print, and putting “> filename” to print to the file. For PDF conversion under OS X, put in “> ~/Desktop/file.ps”, then double-click on it in finder, which will open Preview to convert to a PDF (you can then save in Preview).

Before and after:

200802021854200802021854-1

. Bookmark the permalink. Both comments and trackbacks are currently closed.

One Comment

  1. Posted February 22, 2008 at 4:59 am | Permalink

    I’d be interested to see how InkScape’s algorithm compares to the Standford one at http://vectormagic.com/