Skill: zhaomenghuan/local-image-search (version 1.0.0)

--- name: local-image-search description: Fast local image search using macOS Spotlight or fd. Search images by name, date, location, or metadata. Use when users need to find images on their local machine quickly without manual browsing. --- # Local Image Search Search local images quickly using macOS Spotlight or fd. ## Quick Start ### Search by Name ```bash # Using fd (fastest) fd -e jpg -e png -e jpeg -e heic -e webp -e gif -e tiff "pattern" /path/to/search # Using Spotlight mdfind -onlyin /path/to/search "kMDItemDisplayName == '*pattern*'" ``` ### Search by Date ```bash # Today mdfind -onlyin ~/Pictures "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.today()" # Last 7 days mdfind -onlyin ~/Pictures "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.now(-604800)" # This month mdfind -onlyin ~/Pictures "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.this_month()" ``` ### Search by Location (GPS) ```bash # Has GPS coordinates mdfind "kMDItemContentTypeTree == 'public.image' && kMDItemGPSStatus == 'GPS'" # In specific area (approximate) mdfind "kMDItemContentTypeTree == 'public.image' && kMDItemGPSLatitude > 39 && kMDItemGPSLatitude < 41" ``` ### List All Images ```bash # All images in home mdfind "kMDItemContentTypeTree == 'public.image'" # Specific directory only mdfind -onlyin ~/Pictures "kMDItemContentTypeTree == 'public.image'" # Specific types only mdfind -onlyin ~/Pictures "kMDItemContentType == 'public.png'" ``` ## Available Scripts ### Basic Search - `scripts/search_by_name.sh` - Search images by filename pattern - `scripts/search_by_date.sh` - Search by creation/modification date - `scripts/list_all.sh` - List all images in a directory ### Advanced Search - `scripts/search_by_location.sh` - Search by GPS coordinates - `scripts/search_by_size.sh` - Search by image dimensions - `scripts/search_similar.sh` - Find visually similar images (requires perceptual hash) ### Utility - `scripts/thumbnail.sh` - Generate thumbnails for results - `scripts/copy_results.sh` - Copy search results to destination ## Image Types Supported | Extension | Type | |-----------|------| | jpg/jpeg | JPEG images | | png | PNG images | | heic | iPhone photos | | webp | WebP images | | gif | GIF images | | tiff | TIFF images | | raw | RAW camera files | | dng | Digital negatives | ## Metadata Search Keys | Key | Description | |-----|-------------| | kMDItemDisplayName | Filename | | kMDItemFSContentChangeDate | Modification date | | kMDItemContentCreationDate | Creation date | | kMDItemPixelWidth | Image width | | kMDItemPixelHeight | Image height | | kMDItemGPSLatitude | GPS latitude | | kMDItemGPSLongitude | GPS longitude | | kMDItemMake | Camera make | | kMDItemModel | Camera model | ## Examples ```bash # Find all screenshots ./scripts/search_by_name.sh "Screen Shot" ~/Desktop # Find photos from today ./scripts/search_by_date.sh today ~/Pictures # Find iPhone photos ./scripts/search_by_name.sh "IMG_" ~/Pictures # Copy results to folder ./scripts/search_by_date.sh today ~/Pictures | ./scripts/copy_results.sh ~/Desktop/today_photos ``` ## Requirements - macOS (uses Spotlight/mdfind) - fd (optional, for faster filename search): `brew install fd` - exiftool (optional, for advanced metadata): `brew install exiftool`

path: scripts/copy_results.sh
content: #!/bin/bash
# Copy search results to destination folder
# Usage: cat results.txt | copy_results.sh <destination_folder>

DEST="$1"

if [ -z "$DEST" ]; then
    echo "Usage: cat search_results.txt | $0 <destination_folder>"
    exit 1
fi

mkdir -p "$DEST"

while IFS= read -r file; do
    if [ -f "$file" ]; then
        cp "$file" "$DEST/"
        echo "Copied: $(basename "$file")"
    fi
done

echo ""
echo "Files copied to: $DEST"


path: scripts/list_all.sh
content: #!/bin/bash
# List all images in a directory
# Usage: list_all.sh [directory]

DIR="${1:-$HOME}"

echo "Finding all images in: $DIR"
echo ""

# Try mdfind first, fallback to find
if command -v mdfind &> /dev/null; then
    RESULT=$(mdfind -onlyin "$DIR" "kMDItemContentTypeTree == 'public.image'" 2>/dev/null)
    if [ -n "$RESULT" ]; then
        echo "$RESULT"
        exit 0
    fi
fi

# Fallback to find
find "$DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.heic" -o -iname "*.webp" -o -iname "*.gif" -o -iname "*.tiff" -o -iname "*.raw" \) 2>/dev/null


path: scripts/search_by_date.sh
content: #!/bin/bash
# Search images by date
# Usage: search_by_date.sh <today|week|month> [directory]

PERIOD="$1"
DIR="${2:-$HOME/Pictures}"

if [ -z "$PERIOD" ]; then
    echo "Usage: $0 <today|week|month> [directory]"
    echo "Example: $0 week ~/Pictures"
    exit 1
fi

case "$PERIOD" in
    today)
        mdfind -onlyin "$DIR" "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.today()"
        ;;
    week)
        mdfind -onlyin "$DIR" "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.now(-604800)"
        ;;
    month)
        mdfind -onlyin "$DIR" "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.this_month()"
        ;;
    year)
        mdfind -onlyin "$DIR" "kMDItemContentTypeTree == 'public.image' && kMDItemFSContentChangeDate > $time.this_year()"
        ;;
    *)
        echo "Unknown period: $PERIOD"
        echo "Use: today, week, month, or year"
        exit 1
        ;;
esac


path: scripts/search_by_location.sh
content: #!/bin/bash
# Search images by GPS location
# Usage: search_by_location.sh [directory]

DIR="${1:-$HOME}"

echo "Images with GPS coordinates in: $DIR"
echo ""

mdfind -onlyin "$DIR" "kMDItemContentTypeTree == 'public.image' && kMDItemGPSStatus == 'GPS'"


path: scripts/search_by_name.sh
content: #!/bin/bash
# Search images by filename pattern
# Usage: search_by_name.sh <pattern> [directory]

PATTERN="$1"
DIR="${2:-$HOME}"

if [ -z "$PATTERN" ]; then
    echo "Usage: $0 <pattern> [directory]"
    echo "Example: $0 'screenshot' ~/Desktop"
    exit 1
fi

# Check if fd is available
if command -v fd &> /dev/null; then
    fd -e jpg -e jpeg -e png -e heic -e webp -e gif -e tiff -e raw "$PATTERN" "$DIR"
else
    # Fallback to find + grep
    find "$DIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.heic" -o -iname "*.webp" -o -iname "*.gif" -o -iname "*.tiff" -o -iname "*.raw" \) 2>/dev/null | grep -i "$PATTERN"
fi


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)