The scaling commands let you change the physical dimensions of an image directly from the terminal.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Adarsh275/Image-Transformation/llms.txt
Use this file to discover all available pages before exploring further.
upscale enlarges an image by repeating each pixel a fixed number of times in both axes, while downscale reduces it by sampling every n-th pixel. Both commands prompt you for an integer factor after loading the source file and follow the standard python main.py <command> <src> <dest> syntax. For more granular control — including non-uniform width and height factors — the underlying resize() method is available in the Python API but is not exposed as a CLI command.
upscale
Theupscale command enlarges an image by a uniform integer factor f. Each pixel is repeated f times along both the horizontal and vertical axes using np.repeat(), so a factor of 2 doubles both the width and the height, and a factor of 3 triples them. The operation preserves every original pixel value exactly — no interpolation is applied.
Only integer factors are accepted. Passing a decimal value (e.g.,
1.5) will raise a ValueError because the implementation calls int() on your input.- Interactive prompt:
Enter scaling factor:— integer (e.g.,2) - Output suffix:
_upscaled
peslogo_upscaled.jpg
The output image will be exactly twice the width and twice the height of the source.
downscale
Thedownscale command reduces an image by sampling every f-th pixel in both dimensions using the NumPy slice [::f, ::f]. A factor of 2 retains every second pixel, halving both dimensions; a factor of 4 retains every fourth pixel, reducing each dimension to one quarter of the original. Pixels that fall between sampled positions are discarded entirely — no averaging or interpolation is performed.
Only integer factors are accepted. Passing a decimal value (e.g.,
2.5) will raise a ValueError because the implementation calls int() on your input.- Interactive prompt:
Enter downscale factor:— integer (e.g.,2) - Output suffix:
_downscaled
building_downscaled.jpg
The output image will be exactly half the width and half the height of the source.
Advanced Scaling: the resize() API method
The CLI upscale and downscale commands both apply the same factor to width and height. If you need non-uniform scaling — for example, doubling the width while halving the height — the imageEdit class exposes a resize() method that accepts separate width and height factors:
resize() handles all four combinations automatically:
w > 1andh > 1: upscale both axes withnp.repeat()w > 1andh ≤ 1: upscale width, downscale heightw ≤ 1andh > 1: downscale width, upscale heightw ≤ 1andh ≤ 1: downscale both axes via slice