Eye4Software Hydromagic

  Hydrographic Survey Software


Download free demo version



Resizing Raster Images using QGIS

This tutorial explains how to resize large raster images (for instance satellite or drone imagery) to a slightly lower resolution in case of memory limitation or processing speed issues. Using this method, your images may loose some (little) detail, but georeferencing, aspect ratio and projection information will be preserved.

To "rewarp" the raster image, QGIS is used, which is a free and open-source GIS software package and can be downloaded free of charge from the QGIS project website. As of May 2022, the latest version of QGIS is "QGIS 3.24 Tisler", the version we used to write this tutorial. The instructions below may apply to future versions as well.

QGIS can be downloaded free of charge from their website
QGIS can be downloaded free of charge from their website.


Loading the source image

After starting the QGIS software, load the source image file first. In this tutorial we only cover JPEG and TIFF files because they are used the most. When you also have a "world file" (jpw file extension for JPEG images, tfw file extension for TIFF images, or wld file extension for all formats), make sure it is in the same folder as the images file. The same goes for an optional projection file (prj file extension). QGIS will automatically detect the additional files when loading the image file, no need to specify them.

From the main menu, select the "Add Raster Layer..." option from the "Layer" => "Add Layer" menu item. In the window which appears, click the browse button ( "..." ) to select the image file. Please note that you only have to select the JPEG or (Geo)TIFF file. QGIS will automatically load any additional world or projection data files.

Use the QGIS Data Source Manager to add the raster layer
Use the QGIS Data Source Manager to add the raster layer.

After selecting the image file name, more (format specific) options will appear which you can ignore in most cases. Next click the "Add" button to load the map. This could take a couple of seconds, depending on the size of the image. When done, click the "Close" button to close the "Data Source Manager".

The image file should now be visible in the layers panel. If this panel isn't visible, check the "Layers" item under the "View" => "Panels" item in the main menu. When you located the file, right click the file name and select the "Properties" option from the popup menu to show detailed information on the data.

Consult the layer properties for more info on georeferencing, dimension and projection.
Consult the layer properties for more info on georeferencing, dimension and projection.

In the "Layer Properties" window, make sure the "Information" tab has been selected. A lot of information about the file is displayed, like image resolution, information retrieved from the world file, and map projection (coordinate reference system) information in case a projection file was present during loading.

In this example, no projection file was found, the image size is 29184x25344 pixels and the origin and pixel size correspondents with the following world file:

            0.0373227689 (X pixel size in meters)
            0.0000000000 (Y skew)
            0.0000000000 (X skew)
           -0.0373227680 (Y pixel size in meters)
    -12066521.2497501802 (X coordinate of upper-left pixel)
      7269256.9175442336 (Y coordinate of upper-left pixel)
        
World file which correspondents with the information in QGIS.


Resizing the image

In order to resize the dimensions of the map, we have to change the size of a single pixel. To scale the map in this example to about 50% of its original size, this means that the new pixel size should be increased to about 7.4 centimeters. To achieve this, the image has to be re-generated and an interpolation algorithm must be used to calculate the new color values for all pixels. QGIS offers a tool which can generate a new image file with a new pixel size while maintaining a correct world file and without distorting the image.

To start this tool, select the "Warp (Reproject)..." option from the "Raster" => "Projections" menu at the top of the QGIS program window.

The QGIS Image warping or reprojection tool
The QGIS Image warping or reprojection tool.

To resize the image correctly, please configure the warp tool by following the following steps:

Input File

From the "Input layer" drop down, select the image file you want to process. When you only loaded a single image, it has been selected by default. You can use the browse button (...) next to this drop down box to select another input file name.

Changing the map projection

When you want to change the map projection (coordinate reference system) as well, select a projection for both the "Source CRS" and "Target CRS" settings. When you only want to resize the image, ignore these settings.

Output Resolution

Set the output file resolution. This is what is actually scaling your resulting image. For instance, if the old resolution is 3.7 cm and you want to scale the image size down by 50%, set the new resolution to 7.4 cm - thus resulting in less pixels. To scale down with 10% set to 4.07 cm (Important: enter this value in meters, so for example: 7.4 centimeter becomes 0.074).

Output File

In order to save the changes to your image file, it is required to select an output file name. Please make sure you do not overwrite your original file! Go to the "Reprojected" field and click the "..." button next to it. From the drop down menu which appears, select the "Save To File..." option. A "Save File" dialog will appear which you can use to select the location and name for the output file.

World File

When you want the software to write an updated world file as well (recommended!), expand the "Advanced Parameters" section, and enter the following value in the "Additional command-line parameters field":

Now click the "Run" button. If everything goes well your new image file will be written at the specified location. If not, you can check the "Log" tab for more information about the problem. When you are using Hydromagic, copy all the generated files into the same folder, and add the image file to your project. Hydromagic will automatically detect any world or projection files.