The following examples walk through every command in Image Transformation using the sample images bundled in theDocumentation 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.
Input_Image/ directory of the repository. Each example shows the exact command to run, any interactive prompts you will encounter, and the name of the output file that will appear in Output_Image/. Make sure you have activated your virtual environment and that the Output_Image/ directory already exists before running any command.
Commands that require a scaling factor, angle, percentage, or channel composition cannot be driven non-interactively — they always pause and wait for keyboard input. These are:
upscale, downscale, rotate, contrast, rgb-channels, and transparency.Color Operations
Grayscale Conversion
Convertmountains.jpg to a luminance-weighted grayscale image. The tool applies the ITU-R BT.601 weighting (R × 0.299, G × 0.587, B × 0.114) to each pixel.
Edge Detection
Detect edges inbuilding.jpg using a Sobel filter. The image is first converted to grayscale internally, then both horizontal and vertical gradients are computed and combined.
Invert Colors (Negative)
Produce a photographic negative ofWho-are-the-hackers.jpg by flipping every channel value with a bitwise NOT (~).
Contrast Enhancement
Stretch the pixel value range ofcar.jpeg by clipping to the 2nd–98th percentile and remapping to a 0–multiplier range. The multiplier is derived from the percentage you enter.
Enter the contrast percentage at the prompt
80 maps the stretched values onto a 0–204 range (80% of 255).RGB Channel Isolation
Zero out one or more colour channels inmountains.jpg, keeping only the channels you specify. For example, entering rg retains the red and green channels while zeroing blue — producing a yellow-toned result.
Enter the channel composition at the prompt
r, g, and b written in that order: r, g, b, rg, rb, gb, or rgb. Uppercase letters and spaces are rejected and will re-prompt.Transparency
Add an alpha channel topeslogo.jpg by setting each pixel’s opacity to (100 - percentage) / 100 × 255. Entering 40 means 40% transparent, so 60% opaque.
Geometric Operations
Horizontal Flip
Mirrormountains.jpg left-to-right using NumPy’s np.fliplr().
Rotation
Rotatebuilding.jpg by an arbitrary angle. The output canvas is automatically expanded to fit the full rotated image, and any unfilled pixels are set to black (zero).
Enter the rotation angle at the prompt
Scaling Operations
Upscale
Enlargepeslogo.jpg by repeating each pixel along both axes (np.repeat). Entering 2 doubles the width and height.
Enter the scaling factor at the prompt
3 triples each dimension.Downscale
Shrinkbuilding.jpg by sampling every Nth pixel along both axes. Entering 2 halves the width and height.
Using the Python API Directly
Applying multiple transformations via the Python API
Applying multiple transformations via the Python API
You can import the The same pattern applies to any other method. For example, to upscale programmatically without an interactive prompt, you can set the internal state directly:
imageEdit class directly and chain operations in a script without going through the CLI. This is useful when you want to process many images in a loop or apply several transformations to the same source file.The example below applies grayscale and edge detection to mountains.jpg, saving each result as a separate file: