7

How do I scale down an image to a smaller size in GIMP without an unnecessary loss of resolution? I know that I am losing too much image resolution because when I downscale the same image using HTML code and display it in a web browser I am getting a noticeably sharper resolution. By noticeably sharper I mean that details that were completely absent in the downscaled image in GIMP are displayed the way they should be in the web browser, and the difference in resolution is easily visible without zooming in on the image.

enter image description here
Original image

enter image description here
Downscaled image

I have already tried the answers to the following two questions, but none of the answers gave me the same image resolution that I am getting with my HTML code.

I am not looking for recommendations for web applications or services. I want to find a way to downscale images locally in my computer without an unnecessary loss of resolution.

6
  • I didn't provide my HTML code in the question because you can see the same loss of resolution in GIMP itself, but in case anyone wants to know my HTML code, I used the HTML <img> width and height attributes.
    – karel
    Commented Feb 18, 2016 at 9:43
  • 1
    It mainly depends on the kind of image. Changing the resolution of the image unavoidably changes the pixels of the image itself, and the pixel don't have semantic, just position and color (unlike vector images, which you can scale down with good results). Downscaling an image can emphasize some regularity, resulting e.g. in lines or grids not noticeable before. If you start form a bitmap image and you don't wont a loss of details, you can crop the image or redesign the web page or resize the image and tweak it until satisfied. Next time, choose from begin the size or use a vector format. Commented Feb 18, 2016 at 11:29
  • 1
    P.S. post please an example of your image and of the artifacts you have noticed. Commented Feb 18, 2016 at 11:30
  • I have converted my original .png image to Scalable Vector Graphics (SVG) format without it losing any details and without visual artifacts.
    – karel
    Commented Feb 18, 2016 at 11:57
  • 2
    I opened the .svg file that I made in Inkscape and exported it as a .png image with File -> Export Bitmap and it worked. Because it's your idea, if you post it as an answer, I will accept it. Thanks so much. This was much easier to do than my original idea of resizing it in GIMP.
    – karel
    Commented Feb 18, 2016 at 13:25

6 Answers 6

7

Scaling bitmaps is never without loss. Both upscaling, and downscaling will produce interpolation artifacts. This can be done much better with vector graphics. So if we can trace the bitmap we will get better results.

Scaling artifacts become even more obvious when done on an indexed image. We can not calculate interpolated colors on downscaling an indexed image.

To still be able to scale an indexed image we should therefore change the image mode to RGB before we scale it. Details on downscaling will then be much better preserved:

enter image description here

If we need an indexed image mode we can change it back after scaling.

1
  • Changing the image mode to RGB was what I was looking for, so when you downscale you will cover the loss with semi-transparent pixels to simulate the original smoothness. Mode can be switched under Image- > Mode -> RGB Commented Nov 6, 2017 at 14:56
3

This answer was suggested by Paolo Gibellini in two comments. It's also possible to downscale an image without losing too much resolution in GIMP using a similar method, however I prefer to use Inkscape because it's a lot easier to do it with Inkscape.

  1. The original image can be a file format like .png, .svg, .jpg, etc., preferably .png or .svg because Inkscape will save .jpg images as .png files.

  2. Open the original image file in Inkscape. When you open the file, Inkscape will open a small window asking you to select either link or embed image. Click the radio button to select embed.

  3. Select File -> Export Bitmap. This will open a little Export Bitmap window.

  4. Under the Export area heading in the Export Bitmap window click the Page button.

  5. Under the Bitmap size heading in the Export Bitmap window select new values for Width and Height to downscale the image.

  6. Click the Browse button and browse to the folder in which the file will be saved.

  7. Type a name for the exported file with a .png extension to save it as a .png file or with an .svg extension to save it as a .svg file, etc.

  8. Click the Save button.

  9. Click the Export button.

2

An answer using only raster image processing

Technically you lose resolution when you downscale, since you are displaying the same image with less pixels. The question is therefore to avoid more resolution loss than strictly necessary. The extra resolution loss is usually due to spatial frequency folding, so these high frequencies must be removed before scaling down. And suppressing high spatial frequencies is just blurring the image. So:

  • Filter>Blur>Gaussian blur
  • Use a blur radius equal to your scaling factor (1024->240, blur radius=4.3, note that Gimp will let you enter the radius as 1024/240 and do the computation for you).
  • Once the blur is applied, Image>Scale image

enter image description here

  • You can restore a bit of visual pop using a sharpening filter (here: Filters>Enhance>Unsharp mask with radius=1 and amount=1)

enter image description here

1

I remember reading a long time ago an article where the suggested steps were to resize in 0.5x increments and applying Unsharp Mask (0.6 radius, 1 threshold if I remember correctly).

For example, if initial image is 3300x3300 and you want to resize it to 200x200:

  1. Resize to 1650x1650 (using the best interpolation algorithm, e.g. cubic)
  2. Apply Unsharp Mask 0.6/1 once.
  3. Resize to 825x825
  4. Apply Unsharp Mask 0.6/1 once.
  5. Resize to 412x412
  6. Apply Unsharp Mask 0.6/1 once.
  7. Resize to 200x200 (don't want to do resize 206x206 and then 200x200 since that will lose quality)

Here is an example of an article which demonstrates the difference of 1-step resize and multiple-step resize. It also shows the difference of applying unsharp mask before the each resize vs after. Note it uses different parameters for Unsharp Mask, so you may need to experiment.

0
1

Textbook method is Sinc/Lanczos downsample method on scale. Unfortunately, this has been removed in 2.10.

Something similar to Sinc is gaussian blur followed by scale with NONE interpolation.

1

If the downscaling factor is an integer, e.g., we want to scale by 2x from exactly 800x600 to 400x300, then the best results (in most cases at least) would be obtained by using area downscaling (see here). Unfortunately it does not seem to be implemented in GIMP (for some incomphrehensible reason since it would be something like 5 lines of code).

However, there's a hack that allows working around this which works at least in version 2.10.36:

  1. Blur -> Linear motion blur. Angle 0, length 1 (*
  2. Blur -> Linear motion blur. Angle 90, length 1
  3. Image -> Scale image ... -> Interpolation: None

The reason this works is that the two 90-degree "motion blurs" result to a box blur filter and area downscaling is the same thing as a suitable box blur + downscaling with nearest neighbor.

*) Blur length 1 works for 2x downscaling. For 3x, use 2, 4x, use 3, etc. (N-1 for N-fold downscaling). Also note that this might resuts to some artefacts near the image edges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.