Skip to content

Instantly share code, notes, and snippets.

@luketn
Created January 31, 2026 00:02
Show Gist options
  • Select an option

  • Save luketn/f658365dc6335120c424e13a85e2b290 to your computer and use it in GitHub Desktop.

Select an option

Save luketn/f658365dc6335120c424e13a85e2b290 to your computer and use it in GitHub Desktop.
Image Info Skill

Image Info Skill

A Claude Code skill that analyzes image files to extract dimensions, format, and metadata.

Installation

The skill is now installed in your ~/.claude/skills/image-info/ directory.

Requirements

The skill requires Python 3 and the Pillow library. The skill automatically creates a virtual environment in ~/.claude/skills/image-info/venv and installs Pillow there on first use.

To manually set up the virtual environment:

python3 -m venv ~/.claude/skills/image-info/venv
~/.claude/skills/image-info/venv/bin/pip install Pillow

Usage

You can invoke this skill in two ways:

1. Via Skill Command

/image-info path/to/image.jpg

2. By Asking Claude

Just ask Claude naturally:

  • "Analyze this image: path/to/image.png"
  • "Get image info for screenshot.jpg"
  • "Show me the metadata for photo.jpeg"
  • "What are the dimensions of banner.png?"

What It Shows

The skill extracts and displays:

  • Dimensions: Width and height in pixels
  • Format: Image format (PNG, JPEG, GIF, etc.)
  • Color Mode: RGB, RGBA, L (grayscale), etc.
  • File Size: Human-readable file size
  • Additional Properties: Format-specific metadata
  • EXIF Metadata: Camera info, GPS data, timestamps, etc. (if available)
  • Animation Info: Frame count and duration for GIFs

Supported Formats

All formats supported by Pillow:

  • PNG
  • JPEG/JPG
  • GIF (including animated)
  • BMP
  • TIFF
  • WebP
  • ICO
  • PPM, PGM, PBM
  • And many more

Examples

Basic Image Analysis

/image-info ~/Pictures/vacation.jpg

Output:

============================================================
IMAGE ANALYSIS: vacation.jpg
============================================================

Dimensions:      4032 x 3024 pixels
Format:          JPEG
Mode:            RGB
File Size:       2.45 MB

EXIF Metadata:
------------------------------------------------------------
  Make: Apple
  Model: iPhone 12 Pro
  DateTime: 2024:08:15 14:23:10
  Software: iOS 17.5.1
  ...

PNG with Transparency

/image-info logo.png

Output shows alpha channel info and no EXIF data (PNGs typically don't have EXIF).

Animated GIF

/image-info animation.gif

Output includes frame count and duration information.

Files

  • SKILL.md - Skill definition and instructions for Claude
  • analyze_image.py - Python script that performs the analysis
  • README.md - This documentation file

Troubleshooting

"Pillow library not installed"

  • The skill should automatically create a venv and install Pillow
  • If it fails, manually run: ~/.claude/skills/image-info/venv/bin/pip install Pillow

"File not found"

  • Check the path is correct
  • Use absolute paths or paths relative to your current directory

"Error analyzing image"

  • The file might be corrupted
  • The file might not be a valid image format

Recreating the virtual environment

  • If you need to start fresh, delete the venv directory: rm -rf ~/.claude/skills/image-info/venv
  • The skill will recreate it on next use
#!/usr/bin/env python3
"""
Image Analysis Script
Extracts dimensions, format, and metadata from image files.
"""
import sys
import os
from pathlib import Path
try:
from PIL import Image
from PIL.ExifTags import TAGS
except ImportError:
print("Error: Pillow library not installed.")
print("Install with: pip3 install Pillow")
sys.exit(1)
def format_bytes(size):
"""Convert bytes to human-readable format."""
for unit in ['B', 'KB', 'MB', 'GB']:
if size < 1024.0:
return f"{size:.2f} {unit}"
size /= 1024.0
return f"{size:.2f} TB"
def get_exif_data(image):
"""Extract EXIF metadata from image."""
exif_data = {}
try:
exif = image.getexif()
if exif:
for tag_id, value in exif.items():
tag = TAGS.get(tag_id, tag_id)
exif_data[tag] = value
except AttributeError:
pass
return exif_data
def analyze_image(image_path):
"""Analyze an image file and return its properties."""
# Check if file exists
if not os.path.exists(image_path):
print(f"Error: File not found: {image_path}")
sys.exit(1)
# Get file size
file_size = os.path.getsize(image_path)
try:
# Open the image
with Image.open(image_path) as img:
# Basic info
print("=" * 60)
print(f"IMAGE ANALYSIS: {Path(image_path).name}")
print("=" * 60)
print()
# Dimensions
print(f"Dimensions: {img.width} x {img.height} pixels")
print(f"Format: {img.format}")
print(f"Mode: {img.mode}")
print(f"File Size: {format_bytes(file_size)}")
# Additional format-specific info
if hasattr(img, 'info') and img.info:
print()
print("Additional Properties:")
print("-" * 60)
for key, value in img.info.items():
# Truncate very long values
value_str = str(value)
if len(value_str) > 100:
value_str = value_str[:100] + "..."
print(f" {key}: {value_str}")
# EXIF data
exif_data = get_exif_data(img)
if exif_data:
print()
print("EXIF Metadata:")
print("-" * 60)
# Important EXIF tags to highlight
important_tags = [
'Make', 'Model', 'DateTime', 'DateTimeOriginal',
'Software', 'Orientation', 'XResolution', 'YResolution',
'ExposureTime', 'FNumber', 'ISO', 'Flash',
'FocalLength', 'WhiteBalance', 'GPSInfo'
]
# Show important tags first
for tag in important_tags:
if tag in exif_data:
value = exif_data[tag]
if isinstance(value, bytes):
try:
value = value.decode('utf-8', errors='ignore')
except:
value = str(value)
print(f" {tag}: {value}")
# Show remaining tags
other_tags = {k: v for k, v in exif_data.items() if k not in important_tags}
if other_tags and len(other_tags) <= 20:
print()
print(" Other EXIF data:")
for tag, value in other_tags.items():
if isinstance(value, bytes):
try:
value = value.decode('utf-8', errors='ignore')
except:
value = str(value)
value_str = str(value)
if len(value_str) > 80:
value_str = value_str[:80] + "..."
print(f" {tag}: {value_str}")
elif other_tags:
print(f"\n ({len(other_tags)} additional EXIF fields not shown)")
# Animation info for GIFs
if hasattr(img, 'is_animated') and img.is_animated:
print()
print(f"Animation: Yes ({img.n_frames} frames)")
if hasattr(img, 'info') and 'duration' in img.info:
print(f"Frame Duration: {img.info['duration']} ms")
print()
print("=" * 60)
except Exception as e:
print(f"Error analyzing image: {str(e)}")
sys.exit(1)
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python3 analyze_image.py <image_path>")
sys.exit(1)
image_path = sys.argv[1]
analyze_image(image_path)
name description version tools
image-info
Use this skill when the user asks to "analyze an image", "get image info", "show image metadata", "check image dimensions", "inspect image properties", or wants to extract technical information from image files.
1.0.0
Bash

Image Info Skill

Analyzes image files to extract dimensions, format, and metadata using Python's Pillow library.

Overview

This skill runs a Python script that analyzes image files and outputs:

  • Image dimensions (width x height)
  • Image format (PNG, JPEG, GIF, etc.)
  • Color mode (RGB, RGBA, L, etc.)
  • File size
  • EXIF metadata (if available)
  • Other image properties

Usage

When invoked, this skill will:

  1. Check if Pillow is installed (install if needed)
  2. Run the image analysis script on the specified file
  3. Display all extracted information

Instructions

When a user invokes this skill with an image file path:

  1. First, ensure the virtual environment exists and has Pillow installed:
[ -d ~/.claude/skills/image-info/venv ] || python3 -m venv ~/.claude/skills/image-info/venv && ~/.claude/skills/image-info/venv/bin/pip install Pillow > /dev/null 2>&1
  1. Run the image analysis script using the venv's Python interpreter:
~/.claude/skills/image-info/venv/bin/python ~/.claude/skills/image-info/analyze_image.py "<IMAGE_PATH>"

Replace <IMAGE_PATH> with the actual image file path provided by the user.

  1. Display the output to the user in a clear, formatted way.

Supported Formats

The script supports all formats that Pillow supports, including:

  • PNG
  • JPEG/JPG
  • GIF
  • BMP
  • TIFF
  • WebP
  • ICO
  • And many more

Error Handling

If the file doesn't exist or isn't a valid image, the script will provide a clear error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment