Last active
January 8, 2020 13:01
-
-
Save frozenpandaman/410567cfea6220cb7b89b12182352f75 to your computer and use it in GitHub Desktop.
export psds of manga pages to png (save as indexed png ->remove exif tags -> pngcrush if worth it)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir="_png" | |
mkdir -p $dir # make diretory | |
for filename in *.psd; do # for all .psd files, save as indexed color .png, no transparency | |
if [[ "$filename" == *"-c"* ]]; then # grayscale unless "-c" (i.e. -credits, -color) in filename | |
cs="RGB" | |
else | |
cs="LinearGray" | |
fi | |
convert "$filename"[0] -colorspace $cs -colors 256 -background white -alpha remove -alpha off PNG8:$dir/"${filename%%.*}".png | |
done | |
exiftool -all= $dir/*.png # strip all exif data | |
rm $dir/*_original # clean up | |
for filename in $dir/*.png; do # pngcrush (compress) all files... | |
pngcrush "$filename" "${filename%%.*}.png.crush" | |
I=`stat -f "%z" "$filename"` | |
J=`stat -f "%z" "${filename%%.*}.png.crush"` | |
if [ $I -ge $J ]; then # ...unless resultant file isn't actually smaller | |
mv "${filename%.png}.png.crush" "$filename" | |
else | |
rm "${filename%%.*}.png.crush" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment