mirror of
https://gitlab.com/upRootNutrition/website.git
synced 2025-06-15 20:15:12 -05:00
34 lines
No EOL
939 B
Bash
Executable file
34 lines
No EOL
939 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: $0 <website_url>"
|
|
exit 1
|
|
fi
|
|
|
|
# Create a directory to store images
|
|
mkdir -p downloaded_images
|
|
cd downloaded_images
|
|
|
|
# Counter for image naming, start at 1
|
|
counter=1
|
|
|
|
# Extract image URLs and download
|
|
wget -q -O- "$1" | grep -oE 'https?://[^"]+\.(jpg|jpeg|png|gif)' | while read -r img_url; do
|
|
# Download image
|
|
wget -q "$img_url" -O "temp_image"
|
|
|
|
# Get image width using file size and basic check (approximate)
|
|
width=$(file "temp_image" | grep -oE '[0-9]+ x [0-9]+' | cut -d' ' -f1)
|
|
|
|
# Check if width is over 400
|
|
if [ -n "$width" ] && [ "$width" -gt 400 ]; then
|
|
# Rename to sequential PNG starting from image1.png
|
|
mv "temp_image" "image$counter.png"
|
|
((counter++))
|
|
else
|
|
# Remove images that don't meet criteria
|
|
rm "temp_image"
|
|
fi
|
|
done
|
|
|
|
echo "Downloaded $((counter-1)) images larger than 400px wide" |