Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / misc / make_diskt@2.sh
1 #!/bin/sh
2
3 # exit on all errors
4 set -e
5
6 if [ ! -f "$1" ];then
7         echo "Usage: `basename $0` [imagefile.ext] [-o|-i]"
8         echo "-o will make the bottom of the image be on the outside of the disk"
9         echo "-i will make the bottom of the image be on the inside of the disk"
10         echo
11         echo "Image must be greyscale"
12         echo
13         echo "make sure the imagefile has the right x-y format"
14         echo "run cdrecord driveropts=tattooinfo -checkdrive"
15         echo "to find out"
16         exit 1
17 fi
18
19
20 case "$2" in 
21         -i)
22                 convopts="-flip"
23         ;;
24         -o)
25                 convopts="-flop"
26         ;;
27         *)
28                 echo "error: arg2 must be -o or -i"
29                 exit 1
30         ;;
31 esac
32
33 echo "Make sure the imagefile has the right size"
34 echo "run cdrecord dev=a,b,c driveropts=tattooinfo -checkdrive"
35 echo "to find out"
36 echo
37 echo -n "Converting $1 to disktattoo_image format: "
38
39 ## convert it tp ppm format
40 ## note.. -flop = flip horizontally
41 convert $convopts "$1" "$1-TMP-$$.ppm"
42
43 ## We only need the data, which is the last line in a ppm file
44 ## tail works mighty fine for this (insert evil dirty-coder-laughter here)
45 tail -n+4 "$1-TMP-$$.ppm" > "$1.disktattoo_image"
46
47 ## clean up like a good boy
48 rm "$1-TMP-$$.ppm"
49
50 ## notify user that we're done converting
51 echo "done"
52 echo
53
54 ## stop with stupid code commenting
55 echo "You may now burn '$1.disktattoo_image' to your cd with the command:"
56 echo "cdrecord driveropts=tattoofile=\"$1.disktattoo_image\" -checkdrive"