Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified posts/2024-05-28_gno-golang-serbia/src/thumbs/meetup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 22 additions & 7 deletions posts/thumbs.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
#!/bin/sh -x
#!/bin/sh

MAX_WIDTH=800

for dir in */; do
if [ -d "${dir}src" ]; then
mkdir -p "${dir}src/thumbs"
cd "${dir}src" || continue
if [ ! -d "${dir}src/thumbs" ]; then
mkdir -p "${dir}src/thumbs"
cd "${dir}src" || continue

for img in *.png *.jpg; do
sips --resampleWidth 600 "$img" --out "thumbs/$img"
done
for img in *.png *.jpg; do
if [ -f "$img" ]; then
width=$(gm identify -format "%w" "$img")
if [ "$width" -gt "$MAX_WIDTH" ]; then
gm convert "$img" -resize "${MAX_WIDTH}x" -quality 95 "thumbs/$img" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error processing $img"
fi
else
echo "$img is already less than ${MAX_WIDTH} pixels wide, skipping..."
fi
fi
done

cd ../..
cd ../..
echo "Thumbnails created in ${dir}src/thumbs"
fi
fi
done