Imagemagick

From drpedapati/sciclaw · View interactive version

Imagemagick is an AI agent skill from the GitHub repository drpedapati/sciclaw. Use this skill whenever scientific image assets need deterministic preprocessing (resize, crop, convert, DPI normalization, montage/contact sheets) using ImageMagick 7 `magick`.

How to use this skill

Skill file

ImageMagick Skill

Use this skill for reproducible image preparation in manuscript and presentation workflows.

Primary CLI: magick (ImageMagick 7)

When to Use

Use this skill when a task involves:

Core Rules

  1. Always write to a new output path; do not overwrite originals unless explicitly requested.
  2. Prefer deterministic commands with explicit size, density, and quality values.
  3. Log command and output artifact path in the manuscript/project notes when results support claims.
  4. Standardize on magick command syntax (not legacy convert) for portability in sciClaw.

Quick Recipes

1) Resize to max width while preserving aspect ratio

magick input.png -resize 1600x output-1600w.png

2) Normalize whitespace and add consistent border

magick input.png -trim +repage -bordercolor white -border 20 output-trimmed.png

3) Convert with explicit quality

magick input.tif -quality 92 output.jpg

4) Set DPI metadata for journal pipelines

magick input.png -units PixelsPerInch -density 300 output-300dpi.png

5) Crop exact region

magick input.png -crop 1200x900+100+80 +repage output-crop.png

6) Build contact sheet for fast visual QA

Always quote paths with spaces. Prefer an explicit font (or omit -label if fonts fail). Do not use ../ — set working directory to the image folder and write the sheet in-place. Prefer python-pptx / the pptx skill for slide decks; montage is for QA contact sheets only.

magick montage figure-*.png -font DejaVu-Sans -label '%f' -tile 4x -geometry 600x600+8+8 contact-sheet.png
# Fallback font path on data3/Ubuntu if the name does not resolve:
# magick montage ... -font /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf ...
# No-label fallback:
# magick montage figure-*.png -tile 4x -geometry 600x600+8+8 contact-sheet.png

7) First page of PDF to PNG for preview/review

magick -density 300 manuscript.pdf[0] -quality 95 manuscript-page1.png

Scientific Workflow Patterns

Figure normalization batch

mkdir -p normalized
for f in figures/*.png; do
  base="$(basename "$f" .png)"
  magick "$f" -trim +repage -resize 1800x -units PixelsPerInch -density 300 "normalized/${base}-norm.png"
done

OCR pre-processing

magick scan.jpg -colorspace Gray -auto-level -sharpen 0x1.0 -density 300 scan-ocr-ready.png

Validation Checklist

Failure Handling

Interoperability Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.