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.
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 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.
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 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.
The upscale version of the sample image looks noticeably different from both the decent Xbrzscale version and the cubic-enlarged version.
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.