imgstat 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/imagestat +46 -3
- package/package.json +2 -2
- package/readme.md +13 -41
package/imagestat
CHANGED
|
@@ -26,11 +26,54 @@ if [ ! -d "$TARGET_DIR" ]; then
|
|
|
26
26
|
mkdir -p "$TARGET_DIR"
|
|
27
27
|
fi
|
|
28
28
|
|
|
29
|
+
# Download images if URL is provided
|
|
29
30
|
# Download images if URL is provided
|
|
30
31
|
if [ -n "$URL" ]; then
|
|
31
|
-
echo "Downloading images from $URL to
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
echo "Downloading images from $URL to temp folder..."
|
|
33
|
+
TEMP_DIR=$(mktemp -d)
|
|
34
|
+
|
|
35
|
+
# Download with wget (no extension restriction to catch all images)
|
|
36
|
+
# -nd: no directories (flatten)
|
|
37
|
+
# -r: recursive (useful if URL is a directory, but works for single file too)
|
|
38
|
+
# -l 1: limit recursion depth to 1 just in case (optional, but safer)
|
|
39
|
+
# --no-parent: don't go up
|
|
40
|
+
wget -nd -H -P "$TEMP_DIR" -e robots=off --user-agent="Mozilla/5.0" "$URL" 2>/dev/null
|
|
41
|
+
|
|
42
|
+
echo "Processing downloaded files..."
|
|
43
|
+
shopt -s nullglob
|
|
44
|
+
for f in "$TEMP_DIR"/*; do
|
|
45
|
+
if [ -f "$f" ]; then
|
|
46
|
+
# Identify format and dimensions (take first frame for animated gifs etc)
|
|
47
|
+
# Use -ping to be faster? identification doesn't need full read usually
|
|
48
|
+
ID_OUTPUT=$(identify -format "%m %w %h" "$f[0]" 2>/dev/null)
|
|
49
|
+
|
|
50
|
+
if [ -n "$ID_OUTPUT" ]; then
|
|
51
|
+
read -r TYPE W H <<< "$ID_OUTPUT"
|
|
52
|
+
|
|
53
|
+
# Normalize extension
|
|
54
|
+
EXT=$(echo "$TYPE" | tr '[:upper:]' '[:lower:]')
|
|
55
|
+
case "$EXT" in
|
|
56
|
+
jpeg) EXT="jpg" ;;
|
|
57
|
+
esac
|
|
58
|
+
|
|
59
|
+
# Get clean basename (remove query params)
|
|
60
|
+
BASENAME=$(basename "$f")
|
|
61
|
+
CLEAN_NAME=$(echo "$BASENAME" | sed 's/[?=&].*//')
|
|
62
|
+
# Remove existing extension if it matches common ones
|
|
63
|
+
CLEAN_NAME="${CLEAN_NAME%.*}"
|
|
64
|
+
|
|
65
|
+
# Construct new filename
|
|
66
|
+
NEW_FILENAME="${CLEAN_NAME}-${W}x${H}.${EXT}"
|
|
67
|
+
NEW_PATH="$TARGET_DIR/$NEW_FILENAME"
|
|
68
|
+
|
|
69
|
+
# Move to target
|
|
70
|
+
mv -n "$f" "$NEW_PATH"
|
|
71
|
+
echo "Saved: $NEW_FILENAME ($W x $H)"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
done
|
|
75
|
+
rm -rf "$TEMP_DIR"
|
|
76
|
+
echo "Download processing complete."
|
|
34
77
|
fi
|
|
35
78
|
|
|
36
79
|
# Export function so xargs can use it
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imgstat",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Recursively rename images with dimensions so LLMs can see them.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"imgstat": "./imagestat",
|
|
7
7
|
"imagestat": "./imagestat"
|
package/readme.md
CHANGED
|
@@ -1,58 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# imgstat
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/imgstat)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
**
|
|
6
|
+
**Give AI context about your images.**
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
LLMs can't see image dimensions. `imgstat` recursively scans directories and renames images to include their size (e.g., `photo.jpg` → `photo-1920x1080.jpg`), so your AI coding assistant knows exactly what it's working with.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
10
|
+
**Features:**
|
|
11
|
+
- **AI-Ready Context**: Embeds dimensions directly in filenames.
|
|
12
|
+
- **Idempotent**: Smartly skips images that are already renamed.
|
|
13
|
+
- **Recursive**: Handles deep directory structures.
|
|
14
14
|
|
|
15
|
-
## Installation
|
|
15
|
+
## Installation & Usage
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
The easiest way if you have Node.js installed:
|
|
17
|
+
**Install:**
|
|
19
18
|
```bash
|
|
20
19
|
npm install -g imgstat
|
|
21
20
|
```
|
|
22
|
-
*Note: Requires a bash environment (Linux, macOS, WSL, or Git Bash).*
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
One-line install from your terminal:
|
|
22
|
+
**Run:**
|
|
26
23
|
```bash
|
|
27
|
-
|
|
24
|
+
imgstat [directory]
|
|
28
25
|
```
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
If you prefer a package manager:
|
|
32
|
-
1. Download the latest `.deb` from the [Releases page](https://github.com/isaac0yen/imgstat/releases).
|
|
33
|
-
2. Install it:
|
|
34
|
-
```bash
|
|
35
|
-
sudo apt install ./imagestat_1.0_all.deb
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Option 4: Manual
|
|
39
|
-
```bash
|
|
40
|
-
git clone https://github.com/isaac0yen/imgstat.git
|
|
41
|
-
cd imgstat
|
|
42
|
-
sudo ./install.sh
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Windows
|
|
46
|
-
1. **Recommended**: Use **WSL** (Ubuntu) and follow "Option 2".
|
|
47
|
-
2. **Git Bash**: Clone the repo and run `./imagestat` directly.
|
|
48
|
-
|
|
49
|
-
## Usage
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
imagestat [directory]
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**Download and process:**
|
|
27
|
+
**Download & Process:**
|
|
56
28
|
```bash
|
|
57
|
-
|
|
29
|
+
imgstat -u https://example.com/images
|
|
58
30
|
```
|