#!/bin/bash ## Make a wallet-sized calendar for 8-up printing on letter-sized paper -- 2009-Oct Eugene Reimer; ## PREREQ: pcal -- from http://pcal.sourceforge.net ## PREREQ: sam2p -- from http://code.google.com/p/sam2p (was: img2ps from http://www.cs.cmu.edu/~chuck/softpg) ## PREREQ: chgsed chg scalepix annotatepix datecvt bc -- from http://ereimer.net/programs/general-purpose-scripts.htm ## PREREQ: mk-calendar-covers -- from user-supplied, although an example is provided in http://ereimer.net/programs/mk-calendar.htm ## PREREQ: ghostscript netpbm imagemagick bash sed bc -- from any Linux-distro, non-Penguins can google for them ## note: ## the way images are annotated based on their filenames may need revision for your naming-conventions; ## to suppress it use "-a 0" on the scalepix cmdline; using filenames without any underscores will also suppress it; ## an example of my filenames: CAL01-Polar-bear-and-cub-on-the-rocks_Churchill_20040717_Eugene~Reimer.jpg ## ## Copyright © 2009 Eugene Reimer; can be used, modified, copied, and distributed or sold under the terms of either the LGPL or the GPL (your choice); ## see http://www.gnu.org/licenses for the details of these terms. USAGE=' cmdline: mk-calendar-8up-wallet-sized [option]... IMAGEFILE... option: -?|--help provide usage info -o|--out=FILENAMEBASE output filenames will have .ps and .pdf added -P NBRxNBR paper-size in PS-points; eg: 595x842 for A4, 612x792 for Letter -m MarginAll left, right, top, & bottom margin (in inches) -l MarginLeft left margin (in inches) -r MarginRight right margin (in inches) -t MarginTop top margin (in inches) -b MarginBottom bottom margin (in inches) -Y BegYear beginning year -M BegMonth beginning month -N NbrMonths nbr months -p FILENAME config-file for pcal, eg: calendar_us.txt -z|--timezone=NBR timezone in pcal-style, negated wrt the usual, eg: 6 for NorthAmerican-Central, -8 for China -d|--dst=PATTERN months needing DST timezone-shifting, eg: "4|5|6|7|8|9|10" for NorthAmerica -n|--norotback suppress even-numbered output-pages being upside-down, for printing with short-axis-duplexing -v verbose output defaults: -o smallpp -P612x792 -m0 -Y2010 -M01 -N15 -p calendar_ca.txt -z6 -d"4|5|6|7|8|9|10" CAL*' ##note the ending stroph shopt -s extglob ##enable extglob for @(...) etc COV=Y; CAL=; IMG=; ##eg: to skip the CAL, IMG steps COV=Y; CAL=Y; IMG=Y; ##run all steps (can use null-value to skip a step) ##==defaults for the cmdline params: PWpt=612; PHpt=792; ##default to 612x792-pts (Letter); use 595x842 for A4 MarL=0.125; MarR=0.125; MarT=0.1875;MarB=0.1875;OUT=smallpp-MargHPmin ##eg: margins for my printer, if 'twere aligned MarL=0.125; MarR=0.125; MarT=0.125; MarB=0.250; OUT=smallpp-MargERkluge ##eg: margins for my printer's misalignment MarL=0.125; MarR=0.125; MarT=0.250; MarB=0.125; OUT=smallpp-MargDAkluge ##eg: margins for Doris's printer's misalignment MarL=0.1968;MarR=0.1968;MarT=0.1968;MarB=0.1968;OUT=smallpp-Marg0.5cm ##eg: margins for Biostatic-printer 0.5-cm MarL=0; MarR=0; MarT=0; MarB=0; OUT=smallpp ##default to Marginless BegYEAR=2010; BegMNTH=01; NbrMNTHS=15 ##default to 15-month calendar starting in 2010-January PCALCONF=calendar_ca.txt ##default to Canadian holidays; see pcal for other choices, eg: calendar_us.txt TIMEZONE=6; ##default timezone for Winnipeg (NorthAmerican-Central) - for the moon-phase info DST="4|5|6|7|8|9|10"; ##default Daylight-Saving-Time months for NorthAmerica - for the moon-phase info ROTBACK=Y; ##default to even-pages upside-down for long-axis-duplex printing VERBOSE=; ##default to non-verbose - controls additional debug-output IMGS="CAL*" ##default to selecting photos with filenames CAL* ##parsing cmdline options with getopt: if [[ $1 == -\? ]];then echo "$USAGE"; exit 0;fi ##because getopt doesn't support question-mark as a short-option TEMP=$(getopt -nmk-calendar -o ho:P:m:l:r:t:b:Y:M:N:p:z:d:nv --long help,out:,timezone:,dst:,norotback -- "$@"); if [ $? != 0 ];then echo "$USAGE"; exit 1;fi if [ $? != 0 ];then echo "$USAGE"; exit 2;fi ##errmsg upon invalid option detected by getopt eval set -- "$TEMP" while true;do case "$1" in ##loop thru getopt result, based on the getopt-example... -h|--help) echo "$USAGE"; exit 0;; -o|--out) OUT="$2"; shift 2;; -P|--papersize) PWpt=${2%x*};PHpt=${2#*x}; shift 2;; -m|--margALL) MarL=$2;MarR=$2;MarT=$2;MarB=$2;shift 2;; -l|--margL) MarL="$2"; shift 2;; -r|--margR) MarR="$2"; shift 2;; -t|--margT) MarT="$2"; shift 2;; -b|--margB) MarB="$2"; shift 2;; -Y|--begyear) BegYEAR="$2"; shift 2;; -M|--begmnth) BegMNTH="$2"; shift 2;; -N|--nbrmnths) NbrMNTHS="$2"; shift 2;; -p|--pcalconf) PCALCONF="$2"; shift 2;; -z|--timezone) TIMEZONE="$2"; shift 2;; -d|--dst) DST="$2"; shift 2;; -n|--norotback) ROTBACK=; shift;; -v|--verbose) VERBOSE=Y; shift;; --) shift;break;; *) echo "getopt Internal Error!"; exit 1;; esac; done [[ "$@" ]] && IMGS="$@" ##any remaining non-option args are the images; none => use default [ $VERBOSE ] && echo "OUT:$OUT MarL:$MarL MarR:$MarR MarT:$MarT MarB:$MarB BegYEAR:$BegYEAR BegMNTH:$BegMNTH NbrMNTHS:$NbrMNTHS PCALCONF:$PCALCONF TIMEZONE:$TIMEZONE DST:$DST ROTBACK:$ROTBACK IMGS:$IMGS" ##--calculate paper-size in inches: PW=$(bc <<<"$PWpt/72") PH=$(bc <<<"$PHpt/72") ##--calculate size of smallpages, in inches, pcal-scaling-units, and pixels: W=$(bc <<<"($PW-$MarL-$MarR)/2"); Wpcal=$(bc <<<"$W/17"); Wpx=$(bc <<<"round($W*300)") ##(relies on round, and scale, from my version of bc) H=$(bc <<<"($PH-$MarT-$MarB)/4"); Hpcal=$(bc <<<"$H/11"); Hpx=$(bc <<<"round($H*300)") [ $VERBOSE ] && echo "smallpage-size: W:$W Wpcal:$Wpcal Wpx:$Wpx H:$H Hpcal:$Hpcal Hpx:$Hpx" if [ $CAL ];then rm -f smallCAL* ##cleanup previous calendar-page output?? for ((pg=0; pg12));do ((year+=1, m-=12));done PG=$(printf "%02d" $pg); M=$(printf "%02d" $m) TZ=$TIMEZONE; [[ $m == @($DST) ]] && ((--TZ)) ##adjust timezone for DST-months eg: 4..10; was $m =~ "^($DST)\$" [ $VERBOSE ] && echo "pcal -f$PCALCONF -m -z$TZ -S -s0.6:0.0:0.0/0.93 -ball -gholiday -Ptabloid -x$Wpcal -y$Hpcal $M $year 1 >smallCAL-pg$PG-$year$M.ps" pcal -f$PCALCONF -m -z$TZ -S -s0.6:0.0:0.0/0.93 -ball -gholiday -Ptabloid -x$Wpcal -y$Hpcal $M $year 1 >smallCAL-pg$PG-$year$M.ps ##was -x0.25 -y0.25 done chgsed -n -q ' ##fix things not changeable via pcal params... s|%%BoundingBox.*|%%BoundingBox: 0 0 306 198|; s|/rval.*|/rval 0 def|; s|/ytval.*|/ytval 792 85 sub 10 sub def|; ##scale+rotate changes (margin revisions to BB??) /\/[a-z]*fontsize/{s| 48 | 40 |; s| 25 | 28 |; s| 12 | 20 |; s| 6 | 18 |;} ##fontsize changes ' smallCAL*ps ##fixups applied to each smallCAL*ps file cat smallCAL-pg00* |sed "/^%%Page:/,\$d; 3,/^%%ProofMode:/c%%BoundingBox: 0 0 $PWpt $PHpt" >defsCal.ps ##save one copy of pcal-defines, but with paper-sized-BB chgsed -n -q '1,/^%%EndPageSetup/d; /^%%PageTrailer/,$d' smallCAL*ps ##simplify pcal-produced postscript in smallCAL*ps files fi ##endif $CAL if [ $IMG ];then rm -f smallIMG* ##cleanup previous smallIMG output?? for img in $IMGS;do ((++K));done ##count supplied imagefiles if ((KNbrMNTHS));then echo "mk-calendar: $K images supplied, $((K-NbrMNTHS)) of them ignored";fi ##grumble & continue if too many ((pg=0)); for img in $IMGS;do ##for each image... prf=smallIMG-pg$(printf "%02d" $pg)- scalepix -t0 -s${Wpx}x$Hpx -DI -CA -a25 -b25 -PR=$prf $img ##scale to exactly Wpx x Hpx (was 1275x825), annotate-w-Caption @25px (6pt), add filename-prefix for I in $prf*jpg;do true;done ##img2ps -d 300 -pw $W -ph $H -wt 0 $I ${I/jpg/eps} ##convert to EPS with img2ps; it insists on space between keywd and opnd; was 4.25 2.75 sam2p -j:quiet -m:dpi:17.28 $I ${I/jpg/eps} ##convert to EPS with sam2p; quirky units: what others call DPI must be specified as 72*72/DPI rm -f $I ##no need to keep the JPEG file if ((++pg>=NbrMNTHS));then break; fi ##leave after enough images; have grumbled above done ##gsed -n -q '1,/^\/origstate/d; /^origstate restore/,$d' smallIMG*ps ##simplify img2ps-produced postscript in smallIMG*ps files chgsed -n -q '1,/^%%Page:/d; /^end restore/,$cend restore' smallIMG*ps ##simplify sam2p-produced postscript in smallIMG*ps files fi ##endif $IMG if [ $COV ];then rm -f smallpage* ##cleanup previous smallpage output?? . mk-calendar-covers ##the part that'll need customization; it supplies smallpage{01,32}.ps, optionally 30,31, etc fi ##endif $COV ##if [ $BKLT ];then for ((pg=NbrMNTHS; pg--;));do ##rename small{CAL,IMG} files to get numbered smallpage files ((pgIMG=2+pg*2,pgCAL=3+pg*2)); PG=$(printf "%02d" $pg); PGIMG=$(printf "%02d" $pgIMG); PGCAL=$(printf "%02d" $pgCAL); for I in smallIMG-pg$PG*;do true;done; cp $I ${I/IMG-pg$PG/page$PGIMG} ##could use mv instead of cp when redoing everything for C in smallCAL-pg$PG*;do true;done; cp $C ${C/CAL-pg$PG/page$PGCAL} ##could use mv instead of cp when redoing everything done ##--XY-coords for smallpages within bigpage, for smallpages specified/numbered in column-dominant-order: X0=$MarL; X1=$(bc <<<"$X0+$W"); Y0=$MarB; Y1=$(bc <<<"$Y0+$H"); Y2=$(bc <<<"$Y1+$H"); Y3=$(bc <<<"$Y2+$H") X=( 0 $X0 $X0 $X0 $X0 $X1 $X1 $X1 $X1 ) ##was: X=( 0 0.00 0.00 0.00 0.00 4.25 4.25 4.25 4.25 ) Y=( 0 $Y3 $Y2 $Y1 $Y0 $Y3 $Y2 $Y1 $Y0 ) ##was: Y=( 0 8.25 5.50 2.75 0.00 8.25 5.50 2.75 0.00 ) mkpage () { ##==make one 8-up page ((++BIGPAGENUM)); echo -e "%%Page: $BIGPAGENUM 4\n%%BeginPageSetup\nclear flush\n/PageState save def\n%%EndPageSetup" if [ $ROTBACK ] && ((BIGPAGENUM%2==0));then echo "180 rotate -$PWpt -$PHpt translate";fi ##backsides upside-down; controlled by ROTBACK option for ((J=1;J<=8;++J));do eval PG=\${$J} ##the better way: PG=${!J} echo "gsave ${X[J]} inch ${Y[J]} inch translate %%smallpage$PG"; cat smallpage$PG*; echo "grestore" done echo -e "%%PageTrailer\nshowpage\nclear flush\nPageState restore" } { cat defsCal.ps defscover.txt ##copy defsCal.ps + defscover.txt echo "/inch {72 mul} def" ##def for measurements in inches mkpage 02 31 06 27 04 29 08 25 ##sheet1-front mkpage 28 05 32 01 26 07 30 03 ##sheet1-back mkpage 10 23 14 19 12 21 16 17 ##sheet2-front mkpage 20 13 24 09 18 15 22 11 ##sheet2-back echo -e "%%Trailer\nclear flush\n%%EOF\n" ##ps-trailer } >$OUT.ps; ##postscript result ps2pdf -dAutoRotatePages=/None -dEPSCrop -g${PWpt}x$PHpt -r72 $OUT.ps $OUT.pdf ##make pdf for the postscript-deprived; note: auto-rotate must be avoided!! echo "Resulting calendar is $OUT.ps, or $OUT.pdf" ##all-done msg ##fi ##endif $BKLT exit PCAL OPTIONS: ============= -f file file with holiday definitions -m for new, half, and full moons icons -z time_zone needed for moon-phases (-m); note: sign-convention is reverse of the usual; eg: Winnipeg is -z6 winter, -z5 summer; -S suppress printing the small calendars; they're unreadably tiny at this pagesize -P papersize papersize can be: letter (8.5x11.0 inches) legal (8.5x14.0 inches) a4 (210x297 mm) tabloid (11.0x17.0 inches) -x xscale x-axis scaling factor for the calendar size <--these scale the image, but leave bounding-box unchanged -y yscale y-axis scaling factor for the calendar size -s DNcolor[/fill_color] --color can be 0.0=black..1.0=white, or colon-separated RGB-triplet with each component 0..1; TRIED dull-red .6:.2:.2 for DNcolor -b day1[-day2] | all | holiday --redefines which days get black; ==USE -ball so -gholiday does what's wanted -g day1[-day2] | all | holiday --redefines which days get DNcolor; ==USE -gholiday together with slightly brighter-red .6:0:0 for DNcolor PCAL FIXUPS: ============ ==BEWARE: gview ignores BoundingBox, its auto-detect-pagesize is broken, is misleading wrt Pagesize+Translate+Landscape => not suitable for experiments!! Gimp is fine!! --scale cal-pages by 0.25, and revise %%BoundingBox: 0 0 792 1224 to %%BoundingBox: 0 0 198 306 <--to get 4.25x2.75 inch pages; YUP, works in Gimp; --also omit 90-degree rotate, make %%BoundingBox: 0 0 306 198 (ie: X<-->Y), AND REVISE translate (see below) for a result more to my taste; --Fontsizes: use bigger sz for DayOfWeek text (may go to 3-letter abbrev), and especially for Holiday-Names (may just omit?); CAN reduce sz of title; --Margins: L+R+Bot bigger than needed at 0.170-inches, Top only 0.100 which is already scant, and will shrink with fontsize-changes; after fontsize-changes, L+R 0.170-inches; Bot now a hair less; Top now only 0.085-inches; ==WANT all 4 margins to be 0.125-inches; after fontsize+Adjusting, L+R 0.170-inches; Bot+Top now 0.127-inches; ==MAY WANT Bot:1875 for my HP-printer?? --EXCERPTS of pcal-output, with notes on changes needed: %%BoundingBox: 0 0 792 1224 <==!!==USE %%BoundingBox: 0 0 306 198 for non-rotated 0.25-scaled %%Orientation: Landscape <--omit?? %%DocumentPaperSizes: Tabloid <--omit?? /pagewidth 792 def %%not used /pageheight 1224 def %%not used /rval 90 def %%rotate-opnd <==!!==USE zero to avoid rotation /xsval 0.250 def %%scale-opnd-1 <--specifying -x -y changes ONLY these 2 lines; default: 1.000 /ysval 0.250 def %%scale-opnd-2 <--specifying -x -y changes ONLY these 2 lines; default: 1.000 /xtval 48 def %%translate-opnd-1 /ytval -85 def %%translate-opnd-2 <==!!==USE /ytval -85 792 add def when not rotating; ==ADJUST by -10 to balance Top+Bot-margins /ytop 85 def /daywidth 161 def /dayheight 110 def /dategray [0.600 0.200 0.200] def <--can change via -s option; default: 0.800 /fillgray 0.900 def <--can change via -s option; default: 0.900 /titlefontsize [ 48 60 ] def <==!!==change to [ 40 60 ] -- 2nd nbr not used? /datefontsize [ 25 60 ] def <==!!==change to [ 28 60 ] -- 2nd nbr not used? /weekdayfontsize 12 def <==!!==change to 20 (for day-of-week headings) /notesfontsize 6 def <==!!==change to 18 (for holiday-names) /footfontsize 12 def <--don't know what it's for, but revising to 20 seems safe /headingfontsize 12 def <--don't know what it's for, but revising to 20 seems safe --Note: each PS-file is 777 lines: approx 750 lines of functions, only 25 lines of page-specific stuff; ==SIMPLIFY to use one copy of the functions... IMAGES: ======= scalepix options: (1) -DISTORT for exactly the -sWxH size, (2) -CAPANNO annotate with Caption+Location by Photog YYYY-MM-DD (with hyphen(s) to space) annotatepix was chopping annotation-text; have fixed, so can now use reasonably long caption in 25px (6-point) fontsize; img2ps: to convert JPEG image to EPS; sam2p is an alternative, and seems better... I can't explain the mental gymnastics needed to comprehend sam2p's units, but here's the required formula: what others call DPI must be specified as 72*72/DPI; eg: 300-dpi is specified as dpi:17.28; totally weird but that's what's needed:-) COMBINING: ========== --to myself: SEE notes in /pix/er-Calendar-Making-2009/00-README -- suitable photos are under that dir too; PLAN-A: make PS-file consisting of tiny 4.25x2.75 pages, then use psbook etc to transform into something suitable for printing 8-up on 8.5x11 sheets; PLAN-B: going directly to PS consisting of 8.5x11 pages may well be simpler?? --translate cmds for making an 8-up page -- see /pix/noci0309-LOGOS-selected/BizCard-Eugene.eps for 10-up example; /inch {72 mul} def %%page1-front: gsave 0.00 inch 8.25 inch translate page02 grestore gsave 4.25 inch 8.25 inch translate page04 grestore gsave 0.00 inch 5.50 inch translate page31 grestore gsave 4.25 inch 5.50 inch translate page29 grestore gsave 0.00 inch 2.75 inch translate page06 grestore gsave 4.25 inch 2.75 inch translate page08 grestore gsave 0.00 inch 0.00 inch translate page27 grestore gsave 4.25 inch 0.00 inch translate page25 grestore --for manual-duplexing, optimal page-order may be: pg1-F pg2-F pg2-B pg1-B--??-- CONSIDER: splitting this into two simpler tools, (1) one to make small pcal calendar pages, (2) the other to do booklet-making; the small-page-support perphaps best done via enhancements to pcal C-code; altho my chgsed-fixups are simple and seem workable... the booklet-making tool would take Postscript pages and produce booklet-ized Postscript result, but then psbook, psnup, pstops can already do that?? CHANGE-LOG: =========== Changed my mind about designing it for Flip-on-long-axis duplexing, since backsides then are upside-down for monitor-viewing; Redesigned for Short-axis flipping (aka "tumble" in HP parlance); what was: mkpage 03 30 07 26 01 32 05 28 ##sheet1-back mkpage 11 22 15 18 09 24 13 20 ##sheet2-back becomes: mkpage 28 05 32 01 26 07 30 03 ##sheet1-back mkpage 20 13 24 09 18 15 22 11 ##sheet2-back ==Went back to optional long-axis duplexing because Biostatic only offers that kind; via an option controlling 180-rotate of backsides; mk-calendar-covers: the cmds to construct the covers -- first did manually, but the annotate cmds are too tedious to repeat... coverFront-C1C.ps -- the full-bleed photo with headings written on it; coverFront-C2C.ps -- cmds there too if needed again coverBack.ps -- text+logo for back-cover Considered making smallpage an ARRAY of filenames, to eliminate the renaming to smallpageNN; but that would mess up interface to mk-calendar-covers!! 2009-11-02: New Options: margLR, margTB; for "as is" printing (ie: w/o adobe-reader's ReduceToPrinterMargins option) on printer incapable of marginless printing; eg: my HP-Officejet needs margins of: L+R .125 inches, Top+Bot .1875 => each smallpage is 4.125x2.65625; eg: margins of L+R .125, T+B .25 => smallpage is 4.125x2.625; --considered adding an InnerMargin option, to allow for slight mistakes in quartering the sheets -- but decided against; eg: all margins .125-inches => each small-sheet is 4.00x5.25; each smallpage is 4.00x2.625; NOPE, the usual full-bleed vs non-bleed rules mean it's not needed; they mean that front-cover-image needs annotation-text further from the bottom -- DONE; Method: calculate the new smallpage-size, and scale each to be that size; then the revised 8-up translates will do the rest; previous hardcoded pagesizes: scalepix -s1275x825... <--in pixels img2ps -pw 4.25 -ph 2.75... <--in inches pcal -Ptabloid -x0.25 -y0.25 <--as a ratio wrt x:17-inches y:11-inches --will use inches => lots of bc... --note: cover-pages need Margin-based sizes ==> now "source" it from this script -- so the tinkering remain manageable; --simpler would be a rescaling approach everywhere, but I don't much like that for the image-pages... ARGH, getting misaligned fronts & backs, whether printing PDF from Adobe-Reader, or sending Postscript to lpr ==> fault lies in HP driver or printer itself; quickest test: print Page-2, and measure Top & Bottom margins; Top is always BIGGER than Bottom (when laid-out as equal); ergo need to make Top-Margin smaller than Bottom, and tinker until printed-page has them equal; this is UGLY; consider having to make a different PDF for sending to a printshop where things work correctly... ==Answer on mine is remarkably simple: Top:0.125 Bot:0.25 works!! ==YET TO TRY: an alignment-fixing tool from http://www.linuxprinting.org/download/printing/alignmargins -- see /etc/sbin/alignmargins ROBUSTNESS: to allow for sloppier folding & trimming, have moved photo-annotation-text further away from botton edge + moved bottom text-line on Back-cover up a bit; IMG: annotation-border from default 12 --> 25; ie: 6-points (one-twelfth- or 0.0833-inch), which is 25-pixels in the 300/72 scale; coverFront: bottom-annotation from -y-25 --> -y-30 --that's 0.10-inch (to look right with its bigger fontsize) coverBack: bottom line from y:0.06-inch to 0.104-inch --that's 0.10-inch, based on an additional 797/825 (2.66/2.75) scaling Added a few 2010 "NOCI special days" to calendar_ca.txt; but am yanking those lines in the "published" version; Regimped photos to the correct aspect-ratio: 1.5454 for marginless, 1.553 for min-margins on my printer; ie: 1.55 or even 1.50 is close enough for any margins; Doris picked photos by month, adding a few, dropping a few... have renamed to CAL01ERnnnnn CAL02... --my first draft selected images with: ATTRIBS ER*[A-Z].jpg |grep 'aspect:1.[34567]' |sed 's|\([^:]*\).*|\1|' --now use CAL* --Shortened KildonanSettlersBridge caption -- was too long for Biostatic margins; Redid for conventional (long-axis) duplexing, by rotating even-numbered pages by 180-degrees -- because Biostatic cannot do end-over-end duplexing; --Adobe-Reader, Evince, Kpdf, xpdf all display the PDF as though the 180-rotate ignored==??== Ghostview displays PS correctly, but NOT the PDF; --converting back to ps (pdf2ps) produces the rotate-ignored version ==> is being lost during ps<-->pdf conversions ==AHA, -dAutoRotatePages=/None -- is the answer!! (wrote a small rant on this outrageous idiocy) 2009-11-07: revised interface: mk-calendar-covers now writes smallpage01.ps (front-cover), and smallpage32.ps (back-cover); and, for a calendar of less than 15-months, it also supplies the other smallpages that come after the IMG+CAL pairs; see mk-calendar-covers for more info; tidied up: TIMEZONE, DST, Duplexing-option (to control the even-pages upside-down) 2009-11-08: support cmdline params, using getopt; 2009-11-09: revised DST param to be a pattern for the affected months, so is usable in Europe, southern-hemisphere, etc; also need papersize option; 2009-11-11: switched to sam2p, from img2ps, also in mk-calendar-covers; see http://www.inf.bme.hu/~pts/sam2p/README.txt for cmdline options; it's even more verbose than img2ps, and -j:quiet which is supposed to cure it makes it worse instead; its verbosity goes to stderr, making filtering tough; AHA, newer version (0.44 --> 0.47) cures it -- now -j:quiet works; --while I'm grumbling about verbosity, my scalepix+annotatepix scripts ought to have a hush-up option:-) added image-counting, and grumbling if wrong nbr of images; 2009-11-12: papersize option in PS-points: Letter: 215.9x279.4-mm==8.5x11-in==612x792-ps-pts; A4: 210x297-mm==8.27x11.69-in==595x842-ps-pts; notes on affected parts: W=...8.5...; H=...11... sed '...%%BoundingBox: 0 0 612 792' >defsCal.ps mkpage: 180 rotate -612 -792 translate --also had to fix X1 var and the X array, finishing the margin-changes; --added options to ps2pdf, -dEPSCrop -g${PWpt}x$PHpt -r72, so it will respect the BoundingBox (actually one has to respecify it); 2009-11-14: renamed defscover.ps --> defscover.txt, so it'll be served as a plain-text webpage; 2010-12-18: noticed flaw in getopt usage; handling errors from getopt was missing; added [ $? != 0 ] test after calling getopt; noticed confusing aspect in getopt-etc parameter-parsing WRT long-forms of the various marg* options; is OK though as they have no long-forms to getopt; 2011-01-06: BEWARE: bash-v4 has changed the meaning of =~ within double-square-brackets: specifically what quoting in RHS does; best to avoid it, using == and the extglob extensions since those work everywhere; added: shopt -s extglob revised: [[ $m =~ "^($DST)\$" ]] --> [[ $m == @($DST) ]]