Compare commits

..

No commits in common. "d75c7970265194645848af9d5c7535ebb3ea3d18" and "dffaa00d9f9b7967e88a6ebc22fb27397ad98455" have entirely different histories.

5 changed files with 12 additions and 59 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
test*/

View File

@ -1,9 +0,0 @@
FROM docker.io/debian:12-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
imagemagick \
zenity \
&& rm -rf /var/lib/apt/lists/*
COPY compress /usr/local/bin/
CMD ["compress", "/images/"]

View File

@ -1,12 +0,0 @@
---
services:
app:
build: .
environment:
- DISPLAY=$DISPLAY
- XAUTHORITY=/.Xauthority
volumes:
- ./test/:/images/:ro
- ./test_1080p/:/images_1080p/
- "$XAUTHORITY:/.Xauthority:ro"
- "/tmp/.X11-unix/:/tmp/.X11-unix/"

View File

@ -9,30 +9,6 @@ function wait_queue() {
done
}
function compress() {(
local nb total dir newdir file
cd "$DIR"
dir="$PWD"
total="$(printf '%s\n' * | wc -l)"
newdir="${PWD%/*}/$(basename "$dir")_1080p"
mkdir -p "$newdir"
for file in *; do
"${IDENTIFY[@]}" "$file" 2> /dev/null >&2 \
&& "${CONVERT[@]}" -resize x1080 "$file" "$newdir/$file" &
wait_queue
nb="$(printf '%s\n' "$newdir"/* | wc -l)"
echo "$((nb * 100 / total))"
done
)}
IDENTIFY=(identify)
CONVERT=(convert)
if command -v gm > /dev/null; then
IDENTIFY=(gm "${IDENTIFY[@]}")
CONVERT=(gm "${CONVERT[@]}")
fi
if [ -z "$1" ]; then
set "$(zenity --file-selection --multiple --directory --separator='
')" > /dev/null
@ -43,5 +19,16 @@ if [ -z "$1" ]; then
fi
for DIR in "$@"; do
compress | zenity --progress --title="$DIR"
cd "$DIR"
DIR="$PWD"
NEWDIR="${PWD%/*}/$(basename "$DIR")_1080p"
mkdir -p "$NEWDIR"
for FILE in *; do
wait_queue
identify "$FILE" 2> /dev/null >&2 \
&& convert -resize x1080 "$FILE" "$NEWDIR/$FILE" &
done
done
wait_queue
zenity --info --text="Done"

12
test.sh
View File

@ -1,12 +0,0 @@
#!/bin/bash -e
CONVERT=(convert)
if command -v gm > /dev/null; then
CONVERT=(gm "${CONVERT[@]}")
fi
mkdir -p test test_1080p
"${CONVERT[@]}" -size 3840x2160 xc:black test/000.png
printf '%s\n' {001..127} | xargs -P0 -I'{}' cp test/000.png test/'{}'.png