added stuff
This commit is contained in:
parent
ab17da14dd
commit
c3efb6f06c
1 changed files with 89 additions and 0 deletions
89
cdscript.sh
Normal file
89
cdscript.sh
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# this title font is insanely over the top for what this does
|
||||||
|
# ▄████▄ ▓█████▄ ██████ ▄████▄ ██▀███ ██▓ ██▓███ ▄▄▄█████▓
|
||||||
|
# ▒██▀ ▀█ ▒██▀ ██▌ ▒██ ▒ ▒██▀ ▀█ ▓██ ▒ ██▒▓██▒▓██░ ██▒▓ ██▒ ▓▒
|
||||||
|
# ▒▓█ ▄ ░██ █▌ ░ ▓██▄ ▒▓█ ▄ ▓██ ░▄█ ▒▒██▒▓██░ ██▓▒▒ ▓██░ ▒░
|
||||||
|
# ▒▓▓▄ ▄██▒░▓█▄ ▌ ▒ ██▒▒▓▓▄ ▄██▒▒██▀▀█▄ ░██░▒██▄█▓▒ ▒░ ▓██▓ ░
|
||||||
|
# ▒ ▓███▀ ░░▒████▓ ▒██████▒▒▒ ▓███▀ ░░██▓ ▒██▒░██░▒██▒ ░ ░ ▒██▒ ░
|
||||||
|
# ░ ░▒ ▒ ░ ▒▒▓ ▒ ▒ ▒▓▒ ▒ ░░ ░▒ ▒ ░░ ▒▓ ░▒▓░░▓ ▒▓▒░ ░ ░ ▒ ░░
|
||||||
|
# ░ ▒ ░ ▒ ▒ ░ ░▒ ░ ░ ░ ▒ ░▒ ░ ▒░ ▒ ░░▒ ░ ░
|
||||||
|
# ░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ▒ ░░░ ░
|
||||||
|
# ░ ░ ░ ░ ░ ░ ░ ░
|
||||||
|
# ░ ░ ░
|
||||||
|
#
|
||||||
|
# script to make cd jewerl case inserts easily
|
||||||
|
# by sun https://sx7n8.tech/
|
||||||
|
#
|
||||||
|
# dependencies are:
|
||||||
|
# imagemagick
|
||||||
|
|
||||||
|
# TODO: add super jewel box and "digipack"
|
||||||
|
|
||||||
|
|
||||||
|
# temp directory where images get created before stitching them
|
||||||
|
TMP=/tmp
|
||||||
|
|
||||||
|
|
||||||
|
# message that gets printed if theres missing or unexistant arguments
|
||||||
|
USAGE="Usage: $0 [OPTIONS] [OUTPUT]\nTry '$0 -h' for more information"
|
||||||
|
|
||||||
|
|
||||||
|
# help message
|
||||||
|
HELP="
|
||||||
|
$0: Script to create printable CD jewel case inserts. Uses imagemagick.\n
|
||||||
|
Options:\n
|
||||||
|
-h: shows this message and exits\n
|
||||||
|
-p: sets paper format. options are 'a4' and 'letter'"
|
||||||
|
|
||||||
|
|
||||||
|
# print the usage message if there are no arguments
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo -e $USAGE
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# DPIl; Width and Height in mm
|
||||||
|
A4MM_W="210"
|
||||||
|
A4MM_H="297"
|
||||||
|
LTMM_W="216"
|
||||||
|
LTMM_H="279"
|
||||||
|
DPI='300'
|
||||||
|
|
||||||
|
# function to convert mm to px with dpi
|
||||||
|
CONVERT() { awk -v mm="$1" -v dpi="$2" 'BEGIN{printf("%d", mm/25.4*dpi + 0.5)}'; }
|
||||||
|
|
||||||
|
#
|
||||||
|
A4PX="$(CONVERT "$A4MM_W" "$DPI")x$(CONVERT "$A4MM_H" "$DPI")"
|
||||||
|
LTPX="$(CONVERT "$LTMM_W" "$DPI")x$(CONVERT "$LTMM_H" "$DPI")"
|
||||||
|
|
||||||
|
|
||||||
|
# command line option handling
|
||||||
|
while getopts ":p:h" o; do
|
||||||
|
case "${o}" in
|
||||||
|
h)
|
||||||
|
echo -e $HELP
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
PAPER="$OPTARG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -e $USAGE
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# assign to the 'size' variable the right value
|
||||||
|
if [ "$PAPER" = "a4" ]; then
|
||||||
|
SIZE=$A4PX
|
||||||
|
elif [ "$PAPER" = "letter" ]; then
|
||||||
|
SIZE=$LTPX
|
||||||
|
else
|
||||||
|
echo "what the fuck did you do"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# create a blank file with the specified paper type
|
||||||
|
magick -size $SIZE canvas:white $TMP/front.png
|
Loading…
Add table
Reference in a new issue