diff options
Diffstat (limited to 'webtoons-to-single-image.sh')
-rwxr-xr-x | webtoons-to-single-image.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/webtoons-to-single-image.sh b/webtoons-to-single-image.sh new file mode 100755 index 0000000..0758750 --- /dev/null +++ b/webtoons-to-single-image.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright © 2024 DiffieHellman +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +# Converts vertical comic images into single tall png given a list of directories + +# Return invalid usage if there aren't at least 2 args +[ "$#" -gt 0 ] || exit 2 + +#to_convert is each argument after argv[0] +for to_convert ; do + # Convert file listing to array + files=$(ls "$to_convert"/*.jp*g) + if [[ $files == '' ]] + then + continue + fi + + # Get only the first filename + output=($files) + output=${output[0]%-*}.png + + # Turn all input images into a nice tall .png (most image viewers choke on tall images, but GIMP works fine) + convert -monitor -append $(echo "$files" | sort -V | tr '\n' ' ') "$output" && rm "$to_convert"/*.jp*g +done |