image-tools

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Image Tools Skill

图片工具技能

Image analysis and manipulation tools.
图片分析与处理工具。

When to Use

适用场景

  • Extract image metadata (EXIF, dimensions, format)
  • Convert between image formats
  • Resize or crop images
  • Analyze image content
  • Get image information
  • 提取图片元数据(EXIF、尺寸、格式)
  • 转换图片格式
  • 调整图片尺寸或裁剪图片
  • 分析图片内容
  • 获取图片信息

Image Information

图片信息

Get Image Details

获取图片详情

bash
undefined
bash
undefined

Using file command

Using file command

file image.jpg
file image.jpg

Using identify (ImageMagick)

Using identify (ImageMagick)

identify -verbose image.jpg
identify -verbose image.jpg

Get dimensions

Get dimensions

identify -format "%wx%h" image.jpg
identify -format "%wx%h" image.jpg

Get EXIF data

Get EXIF data

identify -format "%[EXIF:*]" image.jpg
undefined
identify -format "%[EXIF:*]" image.jpg
undefined

Quick Info Script

快速信息脚本

bash
#!/bin/bash
bash
#!/bin/bash

Get basic image info

Get basic image info

FILE="$1" if [ -z "$FILE" ]; then echo "Usage: $0 <image-file>" exit 1 fi
echo "=== Image Info ===" file "$FILE" echo "" echo "Dimensions:" identify -format "%wx%h\n" "$FILE" echo "" echo "Format:" identify -format "%m\n" "$FILE"
undefined
FILE="$1" if [ -z "$FILE" ]; then echo "Usage: $0 <image-file>" exit 1 fi
echo "=== Image Info ===" file "$FILE" echo "" echo "Dimensions:" identify -format "%wx%h\n" "$FILE" echo "" echo "Format:" identify -format "%m\n" "$FILE"
undefined

Image Conversion

图片转换

Convert Formats

格式转换

bash
undefined
bash
undefined

PNG to JPEG

PNG to JPEG

convert input.png output.jpg
convert input.png output.jpg

JPEG to PNG

JPEG to PNG

convert input.jpg output.png
convert input.jpg output.png

Convert to grayscale

Convert to grayscale

convert input.jpg -colorspace Gray output.jpg
convert input.jpg -colorspace Gray output.jpg

Resize

Resize

convert input.jpg -resize 800x600 output.jpg convert input.jpg -resize 50% output.jpg
undefined
convert input.jpg -resize 800x600 output.jpg convert input.jpg -resize 50% output.jpg
undefined

WebP Conversion

WebP格式转换

bash
undefined
bash
undefined

JPEG to WebP

JPEG to WebP

cwebp input.jpg -o output.webp
cwebp input.jpg -o output.webp

PNG to WebP

PNG to WebP

cwebp -lossless input.png -o output.webp
undefined
cwebp -lossless input.png -o output.webp
undefined

Image Analysis

图片分析

Count Colors

统计颜色数量

bash
undefined
bash
undefined

Unique colors in image

Unique colors in image

identify -format "%k" input.jpg
undefined
identify -format "%k" input.jpg
undefined

Image Histogram

图片直方图

bash
undefined
bash
undefined

Get color histogram

Get color histogram

convert input.jpg -format %c histogram:info:-
convert input.jpg -format %c histogram:info:-

Simple histogram

Simple histogram

identify -verbose input.jpg | grep -A 100 "Histogram:"
undefined
identify -verbose input.jpg | grep -A 100 "Histogram:"
undefined

OCR (Text Extraction)

OCR(文本提取)

bash
undefined
bash
undefined

Extract text from image

Extract text from image

tesseract image.jpg stdout
tesseract image.jpg stdout

Specific language

Specific language

tesseract image.jpg stdout -l eng
undefined
tesseract image.jpg stdout -l eng
undefined

Screenshots

截图工具

Capture Screen

捕获屏幕

bash
undefined
bash
undefined

Full screen (Linux)

Full screen (Linux)

import -window root screenshot.png
import -window root screenshot.png

Region selection

Region selection

import screenshot.png
import screenshot.png

Using scrot (if installed)

Using scrot (if installed)

scrot -s selection.png
undefined
scrot -s selection.png
undefined

Capture URL as Image

捕获网页为图片

bash
undefined
bash
undefined

Using wkhtmltoimage

Using wkhtmltoimage

wkhtmltoimage https://example.com page.png
wkhtmltoimage https://example.com page.png

Using chromium headless

Using chromium headless

chromium --headless --screenshot=output.png https://example.com
undefined
chromium --headless --screenshot=output.png https://example.com
undefined

Useful Tools

实用工具列表

ToolPurpose
file
Detect file type
identify
Get image metadata
convert
Format conversion, resize
composite
Blend images
montage
Create image grids
tesseract
OCR text extraction
工具用途
file
检测文件类型
identify
获取图片元数据
convert
格式转换、尺寸调整
composite
图片混合
montage
创建图片网格
tesseract
OCR文本提取

Examples

使用示例

Check if image is valid:
bash
file image.jpg && identify image.jpg >/dev/null 2>&1 && echo "Valid image"
Batch resize:
bash
for f in *.jpg; do convert "$f" -resize 800x600 "thumb_$f"; done
Extract thumbnail:
bash
convert input.jpg -thumbnail 200x200^ -gravity center -extent 200x200 thumb.jpg
检查图片是否有效:
bash
file image.jpg && identify image.jpg >/dev/null 2>&1 && echo "Valid image"
批量调整尺寸:
bash
for f in *.jpg; do convert "$f" -resize 800x600 "thumb_$f"; done
提取缩略图:
bash
convert input.jpg -thumbnail 200x200^ -gravity center -extent 200x200 thumb.jpg