Upscale bitmap images with better results

Most images on the Web are small or medium sized, since otherwise users need to wait longer before their favorite web pages load. However, sometimes you need to find a larger version of an image, but the search doesn’t bear fruit. Any bitmap image can be scaled up or down in an image editor (such as Gimp). But obviously upscaling would not add any detail to the image. Instead, the result will usually be blurred, pixelated and noticeably stretched-up. In this brief roundup we’ll try to upscale bitmap images with a little better result.

There’s no magic in it, just a few advanced scaling algorithms that help produce better-looking pictures. Everything is open source and works great in Fedora. The results will be tested against the Cubic interpolation method, which Gimp applies by default.

Filters in ImageMagick

This is the most famous and widely used open source software for manipulating images from the command line. Fedora, like the majority of other Linux distributions, already includes ImageMagick. Fedora even installs it by default in Fedora Workstation. ImageMagick provides  the convert command, which can also change dimensions of input images.

The trick is that convert supports filters, and ImageMagick provides a rich selection of such filters, some of which work really good for upscaling. You can check out the full list here. For instance, the point filter works well for upscaling pixel art and screen shots, as it preserves clarity and sharpness at the cost of emphasized pixels. Still, this can look better than the blurred results of the convenient Cubic algorithm.

Use it with the following syntax:

convert input.png -filter point -resize 600% output.png

The PNG file format as well as the 600% scaling factor are just examples.

Hiding pixels in Cubic is not really good for upscaling. Use something without anti-aliasing, such as the Point filter in ImageMagick.

Although it’s possible to get the same result in Gimp by choosing the None interpolation method, working with ImageMagick is sometimes easier. Not only it is installed in Fedora Workstation by default (Gimp is available, but not installed), it provides command-line tools which are ideal for scripting.

Xbrzscale

Xbrzscale is a command-line utility that implements the xBR scaling method. In brief, xBR is based on pattern recognition and interpolation, and it’s perfect for magnifying pixel art. xBRZ is an enhanced version of xBR, with a focus on preserving very small details. Therefore, xBRZ delivers pleasing results on both pixel art and photographic images, such as portraits.

In the following side-by-side comparison, the left part definitely looks preferable thanks to the superb clarity.

The Xbrzscale version features sharper edges and looks as if it had more details than the version to the right.

Install Xbrzscale in Fedora

To build this tool from source, you must install some prerequisites first:

sudo dnf -y install gcc-c++ SDL2-devel SDL2_image-devel

Let’s go ahead with Xbrzscale now:

git clone https://github.com/atheros/xbrzscale.git
cd xbrzscale
make

The command line syntax to upscale with this software is:

./xbrzscale X input.png output.png

…where X is the scale factor, a number within the range of 2 to 6.

Note that Xbrzscale always outputs PNG images, no matter what you feed it with. If the input file format is different, Xbrzscale will convert it to PNG.

Smilla Enlarger

Smilla Enlarger has a user-friendly graphical interface. It makes use of yet another different technology, this time based on fractal-based interpolation algorithms. The main goal is to produce sharper results when you upscale photographic images. The enlarged image usually preserves more details than the Cubic interpolation can.

Install Smilla Enlarger in Fedora

Again, start by installing the build dependencies:

sudo dnf -y install qt5-qtbase-devel

Now, build and run Smilla Enlarger:

git clone https://github.com/lupoDharkael/smilla-enlarger.git
cd smilla-enlarger
qmake-qt5 && make
./smilla-enlarger

The application window has numerous advanced controls and extra parameters that put a user in control of upscaling details.

Smilla Enlarger lets you choose a zoom factor, configure cropping and, more importantly, preview the result before hitting the Enlarge & Save button.

The upscale version of the sample image looks noticeably different from both the decent Xbrzscale version and the cubic-enlarged version.

Smill Enlarger adds a subtle amount of grain, which seems to effectively hide artifacts and make a picture look cleaner. Try this application on a photo to get the best results.

It’s hard to recommend the plethora of ImageMagick filters over Xbrzscale and Smilla Enlarger. The actual results will vary across different sorts of images, and of course different user preferences.

Fedora Project community

7 Comments

  1. Don’t forget what may be the best set of image processing filters/algorithms available for FL/OSS users: G’MIC (https://gmic.eu)!

    It’s available as a plugin for GIMP and opens up hundreds of image processing filters and options. There’s 3 different upscaling options available include DCCI2X (Directional Cubic Convolution), diffusion, SCALE2X (awesome for pixel-art images). Give it a look!

  2. Eric

    You should try https://letsenhance.io service. It works very well. You have to buy a plan in order to use it, however you can try it with some images for free (and you should!)

    They make it look like it’s magic.

  3. Luca

    The future is scaling driven by I.A.

  4. Thomas

    You can get similarly impressive results using the same SRGAN algorithm used by letsenhance.io with free software:
    https://github.com/brade31919/SRGAN-tensorflow

    Requirements :
    – python
    – tensorflow
    – SRGAN-tensorflow
    – some pretrained models linked in the aformentionned github project
    – some patience
    – a powerful GPU

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions