image-manipulation-image-magick

작성자: github

ImageMagick을 사용하여 Windows, Linux, macOS에서 이미지를 처리하고 조작합니다. identify 명령어로 이미지 메타데이터, 크기, 형식 정보를 검색합니다. 가로세로 비율 제어 및 썸네일 생성 기능으로 단일 또는 배치 이미지 크기를 조정합니다. 크기나 파일 형식 기준으로 이미지를 필터링하고 처리합니다. ImageMagick이 설치되어 PATH에 magick으로 등록되어 있어야 하며, PowerShell(Windows) 및 Bash(Linux/macOS)용 플랫폼별 설정이 포함됩니다.

npx skills add https://github.com/github/awesome-copilot --skill image-manipulation-image-magick

Image Manipulation with ImageMagick

This skill enables image processing and manipulation tasks using ImageMagick across Windows, Linux, and macOS systems.

When to Use This Skill

Use this skill when you need to:

  • Resize images (single or batch)
  • Get image dimensions and metadata
  • Convert between image formats
  • Create thumbnails
  • Process wallpapers for different screen sizes
  • Batch process multiple images with specific criteria

Prerequisites

  • ImageMagick installed on the system
  • Windows: PowerShell with ImageMagick available as magick (or at C:\Program Files\ImageMagick-*\magick.exe)
  • Linux/macOS: Bash with ImageMagick installed via package manager (apt, brew, etc.)

Core Capabilities

1. Image Information

  • Get image dimensions (width x height)
  • Retrieve detailed metadata (format, color space, etc.)
  • Identify image format

2. Image Resizing

  • Resize single images
  • Batch resize multiple images
  • Create thumbnails with specific dimensions
  • Maintain aspect ratios

3. Batch Processing

  • Process images based on dimensions
  • Filter and process specific file types
  • Apply transformations to multiple files

Usage Examples

Example 0: Resolve magick executable

PowerShell (Windows):

# Prefer ImageMagick on PATH
$magick = (Get-Command magick -ErrorAction SilentlyContinue)?.Source

# Fallback: common install pattern under Program Files
if (-not $magick) {
    $magick = Get-ChildItem "C:\\Program Files\\ImageMagick-*\\magick.exe" -ErrorAction SilentlyContinue |
        Select-Object -First 1 -ExpandProperty FullName
}

if (-not $magick) {
    throw "ImageMagick not found. Install it and/or add 'magick' to PATH."
}

Bash (Linux/macOS):

# Check if magick is available on PATH
if ! command -v magick &> /dev/null; then
    echo "ImageMagick not found. Install it using your package manager:"
    echo "  Ubuntu/Debian: sudo apt install imagemagick"
    echo "  macOS: brew install imagemagick"
    exit 1
fi

Example 1: Get Image Dimensions

PowerShell (Windows):

# For a single image
& $magick identify -format "%wx%h" path/to/image.jpg

# For multiple images
Get-ChildItem "path/to/images/*" | ForEach-Object { 
    $dimensions = & $magick identify -format "%f: %wx%h`n" $_.FullName
    Write-Host $dimensions 
}

Bash (Linux/macOS):

# For a single image
magick identify -format "%wx%h" path/to/image.jpg

# For multiple images
for img in path/to/images/*; do
    magick identify -format "%f: %wx%h\n" "$img"
done

Example 2: Resize Images

PowerShell (Windows):

# Resize a single image
& $magick input.jpg -resize 427x240 output.jpg

# Batch resize images
Get-ChildItem "path/to/images/*" | ForEach-Object { 
    & $magick $_.FullName -resize 427x240 "path/to/output/thumb_$($_.Name)"
}

Bash (Linux/macOS):

# Resize a single image
magick input.jpg -resize 427x240 output.jpg

# Batch resize images
for img in path/to/images/*; do
    filename=$(basename "$img")
    magick "$img" -resize 427x240 "path/to/output/thumb_$filename"
done

Example 3: Get Detailed Image Information

PowerShell (Windows):

# Get verbose information about an image
& $magick identify -verbose path/to/image.jpg

Bash (Linux/macOS):

# Get verbose information about an image
magick identify -verbose path/to/image.jpg

Example 4: Process Images Based on Dimensions

PowerShell (Windows):

Get-ChildItem "path/to/images/*" | ForEach-Object { 
    $dimensions = & $magick identify -format "%w,%h" $_.FullName
    if ($dimensions) {
        $width,$height = $dimensions -split ','
        if ([int]$width -eq 2560 -or [int]$height -eq 1440) {
            Write-Host "Processing $($_.Name)"
            & $magick $_.FullName -resize 427x240 "path/to/output/thumb_$($_.Name)"
        }
    }
}

Bash (Linux/macOS):

for img in path/to/images/*; do
    dimensions=$(magick identify -format "%w,%h" "$img")
    if [[ -n "$dimensions" ]]; then
        width=$(echo "$dimensions" | cut -d',' -f1)
        height=$(echo "$dimensions" | cut -d',' -f2)
        if [[ "$width" -eq 2560 || "$height" -eq 1440 ]]; then
            filename=$(basename "$img")
            echo "Processing $filename"
            magick "$img" -resize 427x240 "path/to/output/thumb_$filename"
        fi
    fi
done

Guidelines

  1. Always quote file paths - Use quotes around file paths that might contain spaces
  2. Use the & operator (PowerShell) - Invoke the magick executable using & in PowerShell
  3. Store the path in a variable (PowerShell) - Assign the ImageMagick path to $magick for cleaner code
  4. Wrap in loops - When processing multiple files, use ForEach-Object (PowerShell) or for loops (Bash)
  5. Verify dimensions first - Check image dimensions before processing to avoid unnecessary operations
  6. Use appropriate resize flags - Consider using ! to force exact dimensions or ^ for minimum dimensions

Common Patterns

PowerShell Patterns

Pattern: Store ImageMagick Path

$magick = (Get-Command magick).Source

Pattern: Get Dimensions as Variables

$dimensions = & $magick identify -format "%w,%h" $_.FullName
$width,$height = $dimensions -split ','

Pattern: Conditional Processing

if ([int]$width -gt 1920) {
    & $magick $_.FullName -resize 1920x1080 $outputPath
}

Pattern: Create Thumbnails

& $magick $_.FullName -resize 427x240 "thumbnails/thumb_$($_.Name)"

Bash Patterns

Pattern: Check ImageMagick Installation

command -v magick &> /dev/null || { echo "ImageMagick required"; exit 1; }

Pattern: Get Dimensions as Variables

dimensions=$(magick identify -format "%w,%h" "$img")
width=$(echo "$dimensions" | cut -d',' -f1)
height=$(echo "$dimensions" | cut -d',' -f2)

Pattern: Conditional Processing

if [[ "$width" -gt 1920 ]]; then
    magick "$img" -resize 1920x1080 "$outputPath"
fi

Pattern: Create Thumbnails

filename=$(basename "$img")
magick "$img" -resize 427x240 "thumbnails/thumb_$filename"

Limitations

  • Large batch operations may be memory-intensive
  • Some complex operations may require additional ImageMagick delegates
  • On older Linux systems, use convert instead of magick (ImageMagick 6.x vs 7.x)

github의 다른 스킬

console-rendering
github
Go에서 struct 태그 기반 콘솔 렌더링 시스템 사용 지침
official
acquire-codebase-knowledge
github
사용자가 기존 코드베이스에 대한 매핑, 문서화, 또는 온보딩을 명시적으로 요청할 때 이 스킬을 사용하세요. "이 코드베이스를 매핑해줘", "문서화해줘"와 같은 프롬프트에서 트리거됩니다.
official
acreadiness-assess
github
현재 리포
official
acreadiness-generate-instructions
github
AgentRC 명령어를 통해 맞춤형 AI 에이전트 지침 파일을 생성합니다. .github/copilot-instructions.md 파일을 생성합니다(기본값, VS Code의 Copilot에 권장됨).
official
acreadiness-policy
github
사용자가 AgentRC 정책을 선택, 작성 또는 적용할 수 있도록 지원합니다. 정책은 관련 없는 검사를 비활성화하고, 영향/수준을 재정의하며, 설정을 통해 준비 상태 점수를 사용자 지정합니다.
official
add-educational-comments
github
코드 파일에 교육용 주석을 추가하여 효과적인 학습 자료로 변환합니다. 설명의 깊이와 어조를 세 가지 설정 가능한 지식 수준(초급, 중급, 고급)에 맞게 조정합니다. 파일이 제공되지 않으면 자동으로 요청하며, 빠른 선택을 위해 번호 목록 매칭을 제공합니다. 교육용 주석만을 사용하여 파일을 최대 125%까지 확장합니다(엄격한 제한: 새 줄 400개, 1,000줄 초과 파일의 경우 300개). 파일 인코딩, 들여쓰기 스타일, 구문 정확성 등을 유지합니다.
official
adobe-illustrator-scripting
github
Adobe Illustrator 자동화 스크립트를 ExtendScript(JavaScript/JSX)로 작성, 디버깅 및 최적화합니다. 스크립트를 생성하거나 수정하여 조작할 때 사용합니다.
official
agent-governance
github
선언적 정책, 의도 분류, AI 에이전트 도구 접근 및 행동 제어를 위한 감사 추적. 구성 가능한 거버넌스 정책은 허용/차단된 도구, 콘텐츠 필터, 속도 제한, 승인 요구 사항을 정의하며, 코드가 아닌 구성으로 저장됨. 의미론적 의도 분류는 패턴 기반 신호를 사용하여 도구 실행 전에 위험한 프롬프트(데이터 유출, 권한 상승, 프롬프트 인젝션)를 탐지함. 도구 수준 거버넌스 데코레이터는 함수에서 정책을 적용함...
official