gallery-manage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gallery Management

图库管理

Manage local gallery content before uploading to S3.
在上传至S3之前管理本地图库内容。

Arguments

参数

  • $ARGUMENTS
    - Command to execute:
    list
    ,
    create
    ,
    validate
    ,
    organize
    , or
    stats
  • $ARGUMENTS
    - 要执行的命令:
    list
    (列出)、
    create
    (创建)、
    validate
    (验证)、
    organize
    (整理)或
    stats
    (统计)

Commands

命令

List Galleries

列出图库

Show all local galleries and their status:
bash
ls -la content/galleries/
显示所有本地图库及其状态:
bash
ls -la content/galleries/

Create New Gallery

创建新图库

Create a properly structured gallery folder:
bash
GALLERY_ID=$1  # e.g., "portrait-002"
CATEGORY=$2    # brands, portraits, events, custom

mkdir -p content/galleries/$GALLERY_ID/{originals,processed,thumbnails,blur}
创建结构规范的图库文件夹:
bash
GALLERY_ID=$1  # 例如:"portrait-002"
CATEGORY=$2    # brands(品牌)、portraits(人像)、events(活动)、custom(自定义)

mkdir -p content/galleries/$GALLERY_ID/{originals,processed,thumbnails,blur}

Create gallery metadata file

创建图库元数据文件

cat > content/galleries/$GALLERY_ID/metadata.json << 'EOF' { "id": "GALLERY_ID_PLACEHOLDER", "title": "", "category": "CATEGORY_PLACEHOLDER", "description": "", "isPublic": true, "isClientGallery": false, "createdAt": "TIMESTAMP_PLACEHOLDER" } EOF
undefined
cat > content/galleries/$GALLERY_ID/metadata.json << 'EOF' { "id": "GALLERY_ID_PLACEHOLDER", "title": "", "category": "CATEGORY_PLACEHOLDER", "description": "", "isPublic": true, "isClientGallery": false, "createdAt": "TIMESTAMP_PLACEHOLDER" } EOF
undefined

Validate Gallery Images

验证图库图片

Check images meet requirements before upload:
bash
GALLERY_PATH=$1  # e.g., "content/galleries/portrait-002"
在上传前检查图片是否符合要求:
bash
GALLERY_PATH=$1  # 例如:"content/galleries/portrait-002"

Check for supported formats

检查支持的格式

find $GALLERY_PATH/originals -type f (
-name ".jpg" -o -name ".jpeg" -o -name ".png"
-o -name "
.webp" -o -name ".heic" -o -name ".heif"
-o -name ".tiff" -o -name ".tif"
) -print
find $GALLERY_PATH/originals -type f (
-name ".jpg" -o -name ".jpeg" -o -name ".png"
-o -name "
.webp" -o -name ".heic" -o -name ".heif"
-o -name ".tiff" -o -name ".tif"
) -print

Check for unsupported formats (should be empty)

检查不支持的格式(结果应为空)

find $GALLERY_PATH/originals -type f (
-name ".cr2" -o -name ".nef" -o -name ".arw"
-o -name "
.gif" -o -name ".bmp" -o -name ".psd"
) -print
find $GALLERY_PATH/originals -type f (
-name ".cr2" -o -name ".nef" -o -name ".arw"
-o -name "
.gif" -o -name ".bmp" -o -name ".psd"
) -print

Check file sizes (warn if > 50MB)

检查文件大小(若超过50MB则发出警告)

find $GALLERY_PATH/originals -type f -size +50M -print
find $GALLERY_PATH/originals -type f -size +50M -print

Count total images

统计图片总数

find $GALLERY_PATH/originals -type f ( -name ".jpg" -o -name ".jpeg" -o -name "*.png" ) | wc -l
undefined
find $GALLERY_PATH/originals -type f ( -name ".jpg" -o -name ".jpeg" -o -name "*.png" ) | wc -l
undefined

Organize Gallery

整理图库

Rename files with consistent naming and ordering:
bash
GALLERY_PATH=$1
使用统一的命名规则和顺序重命名文件:
bash
GALLERY_PATH=$1

Generate sequential names while preserving extension

生成连续命名并保留扩展名

cd $GALLERY_PATH/originals count=1 for file in .{jpg,jpeg,png,webp}; do if [ -f "$file" ]; then ext="${file##.}" newname=$(printf "img-%03d.%s" $count "$ext") mv "$file" "$newname" ((count++)) fi done
undefined
cd $GALLERY_PATH/originals count=1 for file in .{jpg,jpeg,png,webp}; do if [ -f "$file" ]; then ext="${file##.}" newname=$(printf "img-%03d.%s" $count "$ext") mv "$file" "$newname" ((count++)) fi done
undefined

Gallery Statistics

图库统计

Show comprehensive stats for a gallery:
bash
GALLERY_PATH=$1

echo "=== Gallery Statistics ==="
echo "Path: $GALLERY_PATH"
echo ""
显示图库的综合统计信息:
bash
GALLERY_PATH=$1

echo "=== 图库统计信息 ==="
echo "路径: $GALLERY_PATH"
echo ""

Count by type

按格式统计数量

echo "Image counts:" echo " JPG/JPEG: $(find $GALLERY_PATH/originals -name ".jpg" -o -name ".jpeg" | wc -l)" echo " PNG: $(find $GALLERY_PATH/originals -name ".png" | wc -l)" echo " WebP: $(find $GALLERY_PATH/originals -name ".webp" | wc -l)" echo " HEIC: $(find $GALLERY_PATH/originals -name ".heic" -o -name ".heif" | wc -l)" echo ""
echo "图片数量统计:" echo " JPG/JPEG: $(find $GALLERY_PATH/originals -name ".jpg" -o -name ".jpeg" | wc -l)" echo " PNG: $(find $GALLERY_PATH/originals -name ".png" | wc -l)" echo " WebP: $(find $GALLERY_PATH/originals -name ".webp" | wc -l)" echo " HEIC: $(find $GALLERY_PATH/originals -name ".heic" -o -name ".heif" | wc -l)" echo ""

Total size

总大小

echo "Total size:" du -sh $GALLERY_PATH/originals
echo "总大小:" du -sh $GALLERY_PATH/originals

Processed status

处理状态

echo "" echo "Processing status:" echo " Processed variants: $(find $GALLERY_PATH/processed -type f 2>/dev/null | wc -l)" echo " Thumbnails: $(find $GALLERY_PATH/thumbnails -type f 2>/dev/null | wc -l)" echo " Blur placeholders: $(find $GALLERY_PATH/blur -type f 2>/dev/null | wc -l)"
undefined
echo "" echo "处理状态:" echo " 已处理衍生图: $(find $GALLERY_PATH/processed -type f 2>/dev/null | wc -l)" echo " 缩略图: $(find $GALLERY_PATH/thumbnails -type f 2>/dev/null | wc -l)" echo " 模糊占位图: $(find $GALLERY_PATH/blur -type f 2>/dev/null | wc -l)"
undefined

Directory Structure

目录结构

Expected gallery structure:
content/galleries/{gallery-id}/
├── metadata.json      # Gallery metadata
├── originals/         # Original uploaded images
│   ├── img-001.jpg
│   ├── img-002.jpg
│   └── ...
├── processed/         # Generated WebP variants
│   └── img-001/
│       ├── 320w.webp
│       ├── 640w.webp
│       └── ...
├── thumbnails/        # Generated thumbnails
│   └── img-001/
│       ├── sm.webp
│       ├── md.webp
│       └── lg.webp
└── blur/             # Blur placeholders
    ├── img-001.txt
    └── ...
预期的图库结构:
content/galleries/{gallery-id}/
├── metadata.json      # 图库元数据
├── originals/         # 原始上传图片
│   ├── img-001.jpg
│   ├── img-002.jpg
│   └── ...
├── processed/         # 生成的WebP衍生图
│   └── img-001/
│       ├── 320w.webp
│       ├── 640w.webp
│       └── ...
├── thumbnails/        # 生成的缩略图
│   └── img-001/
│       ├── sm.webp
│       ├── md.webp
│       └── lg.webp
└── blur/             # 模糊占位图
    ├── img-001.txt
    └── ...

Workflow Integration

工作流集成

This skill works with other skills in this order:
  1. /gallery-manage create
    - Create new gallery structure
  2. Copy images to
    originals/
    folder
  3. /gallery-manage validate
    - Check images meet requirements
  4. /optimize-images
    - Generate variants and thumbnails
  5. /sync-content
    - Upload to S3
  6. /db-seed
    or API call - Create gallery record in DynamoDB
此工具需按以下顺序与其他工具配合使用:
  1. /gallery-manage create
    - 创建新的图库结构
  2. 将图片复制到
    originals/
    文件夹
  3. /gallery-manage validate
    - 检查图片是否符合要求
  4. /optimize-images
    - 生成衍生图和缩略图
  5. /sync-content
    - 上传至S3
  6. /db-seed
    或API调用 - 在DynamoDB中创建图库记录

Supported Formats

支持的格式

FormatExtensionSupportedMax Size
JPEG.jpg, .jpeg50MB
PNG.png50MB
WebP.webp50MB
HEIC.heic, .heif50MB
TIFF.tiff, .tif50MB
RAW.cr2, .nef, .arwN/A
GIF.gifN/A
PSD.psdN/A
格式扩展名支持情况最大文件大小
JPEG.jpg, .jpeg50MB
PNG.png50MB
WebP.webp50MB
HEIC.heic, .heif50MB
TIFF.tiff, .tif50MB
RAW.cr2, .nef, .arw不适用
GIF.gif不适用
PSD.psd不适用

Output

输出

After each command, report:
  • Action taken
  • Number of files affected
  • Any warnings or errors
  • Next recommended action
每个命令执行后,将报告以下内容:
  • 执行的操作
  • 受影响的文件数量
  • 任何警告或错误
  • 推荐的下一步操作