Compare commits
No commits in common. "d75c7970265194645848af9d5c7535ebb3ea3d18" and "dffaa00d9f9b7967e88a6ebc22fb27397ad98455" have entirely different histories.
d75c797026
...
dffaa00d9f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
test*/
|
|
@ -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/"]
|
|
12
compose.yaml
12
compose.yaml
@ -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/"
|
|
37
compress
37
compress
@ -9,30 +9,6 @@ function wait_queue() {
|
|||||||
done
|
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
|
if [ -z "$1" ]; then
|
||||||
set "$(zenity --file-selection --multiple --directory --separator='
|
set "$(zenity --file-selection --multiple --directory --separator='
|
||||||
')" > /dev/null
|
')" > /dev/null
|
||||||
@ -43,5 +19,16 @@ if [ -z "$1" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for DIR in "$@"; do
|
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
|
||||||
|
done
|
||||||
|
|
||||||
|
wait_queue
|
||||||
|
zenity --info --text="Done"
|
||||||
|
Loading…
Reference in New Issue
Block a user