From c3efb6f06c89a3b8669e336f19e46b0ed823c5c6 Mon Sep 17 00:00:00 2001 From: sun Date: Thu, 28 Aug 2025 12:31:50 +0200 Subject: [PATCH] added stuff --- cdscript.sh | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 cdscript.sh diff --git a/cdscript.sh b/cdscript.sh new file mode 100644 index 0000000..eee449b --- /dev/null +++ b/cdscript.sh @@ -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