forked from patdryburgh/hitchens
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize.sh
More file actions
31 lines (24 loc) · 776 Bytes
/
resize.sh
File metadata and controls
31 lines (24 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Set default DPI (Change this to any value between 72-150)
DPI=96
# Check if ImageMagick is installed
if ! command -v mogrify &> /dev/null; then
echo "Error: ImageMagick is not installed. Install it using:"
echo " sudo apt update && sudo apt install imagemagick -y"
exit 1
fi
# Ensure at least one PNG exists
if ! ls *.png 1> /dev/null 2>&1; then
echo "No PNG files found in the current directory."
exit 1
fi
# Create a backup directory
mkdir -p backup
cp *.png backup/
echo "Converting PNG files to $DPI DPI..."
# Convert all PNG files in the directory
for file in *.png; do
mogrify -density $DPI -units PixelsPerInch "$file"
echo "Converted: $file"
done
echo "Done! Original images are backed up in the 'backup' folder."