Skip to content
Related Articles

Related Articles

Improve Article

Scaling image in R

  • Last Updated : 06 Jun, 2021

In digital image processing or D.I.P., image scaling refers to the resizing of a digital image. Here, we are scaling an image using R Programming language. This is a subpart of the topic image transformations in digital image processing. If we are increasing the size of an image then it means that we are scaling it up and if we are decreasing or making the image the smaller, then it means we are scaling it down. 

Image in use:

Method 1: Using OpenImageR

First install OpenImageR package in Rstudio. OpenImageR is an image processing Toolkit that Incorporates functions for image preprocessing, filtering and image recognition.

The image to be resized is imported to the environment and the required resizing is done using image_scale() function. The image_scale() function is a helper function to draw scale for image. It plots a scale in the right margin of a plot, typically an image plot. We will pass the image and the value as arguments in the function.



The only difference in scaling up or down comes from the size value passed to image_scale() function. To scale up down pass a value smaller than 100 and to up scale a value greater than 100.



img = image_read("gfg.png")

Output :

Method 2: Using magick 

magick is a module in R programming language that provides modern and simple toolkit for image processing. The process completely similar to the above method the difference the package.

image_scale() can also be used to resize image here too and can be deal with height and width at the same time. 


image_scale( image_scale (image, “width”), “height”)



img = image_read("gfg.png")



My Personal Notes arrow_drop_up
Recommended Articles
Page :