🖼 Image Module

The Image module provides simple and powerful image processing utilities including resizing, cropping, rotating, flipping, blurring, converting, thumbnail creation, and compression.


📏 resize()

Resize an image to the specified width and height.

💻 Code

import allkitpy

allkitpy.image.resize(
    "cat.jpg",
    (800, 600),
    "resize.jpg"
)

📤 Output

Image resized successfully.
Saved as resize.jpg

✂️ crop()

Crop a rectangular region from an image.

💻 Code

import allkitpy

allkitpy.image.crop(
    "cat.jpg",
    (100, 100, 500, 400),
    "crop.jpg"
)

📤 Output

Image cropped successfully.
Saved as crop.jpg

🔄 rotate()

Rotate an image by a specified angle. By default, the canvas expands to fit the entire rotated image without cropping.

💻 Code

import allkitpy

allkitpy.image.rotate(
    "cat.jpg",
    90,
    "rotate.jpg"
)

📤 Output

Image rotated successfully.
Saved as rotate.jpg
💡 Tip

Positive angles rotate the image counter-clockwise. Common values:

  • 90°
  • 180°
  • 270°
  • 45°

↔️ flip()

Flip an image horizontally or vertically.

💻 Code

import allkitpy

allkitpy.image.flip(
    "cat.jpg",
    "horizontal",
    "flip.jpg"
)

📤 Output

Image flipped successfully.
Saved as flip.jpg
📌 Available Modes
  • horizontal → Left ↔ Right
  • vertical → Top ↕ Bottom

🌫️ blur()

Apply a Gaussian blur effect to an image. Increasing the blur radius creates a stronger blur effect.

💻 Code

import allkitpy

allkitpy.image.blur(
    "cat.jpg",
    5,
    "blur.jpg"
)

📤 Output

Image blurred successfully.
Saved as blur.jpg
💡 Blur Radius
  • 1 → Light blur
  • 3 → Medium blur
  • 5 → Strong blur
  • 10+ → Very strong blur

🎨 convert()

Convert an image to another color mode.

💻 Code

import allkitpy

allkitpy.image.convert(
    "cat.png",
    "grayscale",
    "gray.png"
)

📤 Output

Image converted successfully.
Saved as gray.png
📌 Supported Modes
  • grayscale → Black & White Image
  • RGB → Standard RGB Color Image
💡 Tip

Use grayscale when preparing images for OCR, document processing, or reducing file size.


🖼️ thumbnail()

Create a thumbnail image while preserving the original aspect ratio. The image is automatically resized to fit within the specified dimensions without distortion.

💻 Code

import allkitpy

allkitpy.image.thumbnail(
    "cat.jpg",
    (200, 200),
    "thumb.jpg"
)

📤 Output

Thumbnail created successfully.
Saved as thumb.jpg
💡 Tip

Thumbnails are commonly used for galleries, websites, previews, and profile pictures.


🗜️ compress()

Compress an image by reducing its quality to produce a smaller file size while keeping the image usable.

💻 Code

import allkitpy

allkitpy.image.compress(
    "photo.jpg",
    75,
    "compressed.jpg"
)

📤 Output

Image compressed successfully.
Saved as compressed.jpg
📊 Quality Guide
Quality Result
100 Best quality, largest file size
90 High quality
75 Balanced quality and size (Recommended)
50 Smaller file size
20 Very small file size, noticeable quality loss
⚠️ Note

Compression is most effective for JPEG images. PNG images use a different compression method and may not show the same reduction in file size.


📋 Summary

The Image module provides simple yet powerful image processing utilities for everyday development tasks. Whether you need to resize, crop, rotate, convert, blur, create thumbnails, or compress images, AllkitPy offers an easy-to-use interface with minimal code.

Function Description
resize() Resize an image to a specified width and height.
crop() Crop a selected region from an image.
rotate() Rotate an image by any angle.
flip() Flip an image horizontally or vertically.
blur() Apply a Gaussian blur effect.
convert() Convert an image to another color mode.
thumbnail() Create a thumbnail while preserving aspect ratio.
compress() Reduce image file size using quality compression.

🚀 Quick Example

import allkitpy

allkitpy.image.resize(
    "photo.jpg",
    (800, 600),
    "output.jpg"
)

🔗 Related Modules

📊 Data Module

Data processing and analysis utilities.

📁 File Module

File operations and management tools.

🔢 Math Module

Mathematical functions and calculations.