Image processing for basic edits and color adjustments. Use this skill when users request image operations like resize, rotate, crop, flip, or color adjustments (brightness, contrast, saturation). Supports both uploaded images and images from URLs.
This skill provides image processing capabilities for basic editing operations and color adjustments. Use the provided Python scripts to perform operations efficiently and consistently. All scripts support both local file paths and image URLs.
Before performing operations, get image information to understand current dimensions and format:
python3 scripts/get_image_info.py <input_path_or_url>
This displays:
All operations use the scripts/process_image.py script with the following pattern:
python3 scripts/process_image.py <input> <output> --operation <op_name> [operation-specific args]
Input sources:
/path/to/image.jpg/mnt/user-data/uploads/filename.pnghttps://example.com/image.jpgOutput location:
/mnt/user-data/outputs/ for files users should access.png, .jpg, etc.) or --format flagResize images to specific dimensions. By default, maintains aspect ratio (recommended).
Maintain aspect ratio (image fits within dimensions):
python3 scripts/process_image.py input.jpg output.jpg \
--operation resize \
--width 800 \
--height 600 \
--maintain-aspect
Exact dimensions (may distort):
python3 scripts/process_image.py input.jpg output.jpg \
--operation resize \
--width 800 \
--height 600
Common use cases:
Rotate images by any angle. Use positive values for clockwise, negative for counter-clockwise.
90° clockwise:
python3 scripts/process_image.py input.jpg output.jpg \
--operation rotate \
--angle 90
Common rotations:
Note: Image dimensions change after rotation (except 180°). The script uses expand=True to prevent cropping.
Crop images to a specific rectangular region using pixel coordinates (left, top, right, bottom).
python3 scripts/process_image.py input.jpg output.jpg \
--operation crop \
--left 100 \
--top 50 \
--right 500 \
--bottom 400
Coordinate system:
get_image_info.py to check current dimensions firstExamples for 1000x800 image:
--left 250 --top 100 --right 750 --bottom 600--left 0 --top 0 --right 500 --bottom 800--left 0 --top 0 --right 1000 --bottom 400Mirror images horizontally or vertically.
Horizontal flip (left-right mirror):
python3 scripts/process_image.py input.jpg output.jpg \
--operation flip \
--direction horizontal
Vertical flip (top-bottom mirror):
python3 scripts/process_image.py input.jpg output.jpg \
--operation flip \
--direction vertical
All color adjustments use a --factor parameter:
Refer to references/image_processing_guide.md for detailed factor ranges and recommendations.
Adjust image brightness (lightness/darkness).
python3 scripts/process_image.py input.jpg output.jpg \
--operation brightness \
--factor 1.3
Factor guide:
Typical range: 0.5 to 2.0 Subtle adjustments: ±0.2 to ±0.5
Adjust contrast between light and dark areas.
python3 scripts/process_image.py input.jpg output.jpg \
--operation contrast \
--factor 1.2
Factor guide:
Typical range: 0.5 to 2.0 Subtle adjustments: ±0.2 to ±0.5
Adjust color intensity/vibrancy.
python3 scripts/process_image.py input.jpg output.jpg \
--operation saturation \
--factor 1.4
Factor guide:
Typical range: 0.0 to 2.0 Special case: Use 0.0 to convert to grayscale
Adjust image sharpness (clarity vs blur).
python3 scripts/process_image.py input.jpg output.jpg \
--operation sharpness \
--factor 1.5
Factor guide:
Typical range: 0.5 to 2.0 Warning: Values >2.0 can introduce artifacts
Convert between image formats by specifying the output file extension or using --format.
By file extension:
# PNG to JPEG
python3 scripts/process_image.py input.png output.jpg --operation brightness --factor 1.0
# JPEG to PNG
python3 scripts/process_image.py input.jpg output.png --operation brightness --factor 1.0
Using --format flag:
python3 scripts/process_image.py input.png output.jpg \
--operation brightness --factor 1.0 \
--format JPEG \
--quality 90
Format considerations:
For best results, perform operations in this sequence:
For images requiring multiple operations, apply operations sequentially:
# Example: Crop, resize, and brighten
python3 scripts/process_image.py input.jpg temp_cropped.jpg \
--operation crop --left 100 --top 100 --right 900 --bottom 700
python3 scripts/process_image.py temp_cropped.jpg temp_resized.jpg \
--operation resize --width 800 --height 600 --maintain-aspect
python3 scripts/process_image.py temp_resized.jpg /mnt/user-data/outputs/final.jpg \
--operation brightness --factor 1.2
Always save to a new filename to preserve the original image. Use descriptive output names:
image_resized.jpgimage_bright.jpgimage_final.jpgFor images from URLs, download and process in one step:
python3 scripts/process_image.py \
"https://example.com/photo.jpg" \
/mnt/user-data/outputs/processed.jpg \
--operation resize \
--width 800 \
--height 600 \
--maintain-aspect
"Make this image brighter" → Use brightness adjustment with factor 1.2-1.5
"Resize this for the web" → Use resize with --maintain-aspect and appropriate dimensions (e.g., 1280x720)
"Rotate this 90 degrees" → Use rotate with --angle 90
"Convert this PNG to JPEG" → Use any operation with .jpg output extension
"Make this image grayscale" → Use saturation with --factor 0.0
"Crop out the background" → Check dimensions first, then use crop with appropriate coordinates
"Make the colors more vibrant" → Use saturation with factor 1.3-1.5
The scripts require:
Install if needed:
pip install Pillow requests --break-system-packages
Main image processing script supporting all basic edits and color adjustments. Handles both local files and URLs.
Utility script to display image information (format, dimensions, mode, file size).
Comprehensive reference with detailed explanations of:
Load this reference when users need detailed guidance on parameters or when providing recommendations for adjustments.