Path: csiph.com!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!panix.com!forkosh From: JohnF Newsgroups: comp.lang.postscript Subject: Re: Putting lines from a file into an array Date: Wed, 3 Aug 2016 06:21:42 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 67 Message-ID: References: <87624kp6hc.fsf@Compaq.site.inet> <61d3b2d1-0318-4be3-959b-b955192dab31@googlegroups.com> <8b56c6b3-1d1d-47d2-aa00-32deffb3fc7c@googlegroups.com> NNTP-Posting-Host: panix3.panix.com X-Trace: reader2.panix.com 1470205302 4953 166.84.1.3 (3 Aug 2016 06:21:42 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 3 Aug 2016 06:21:42 +0000 (UTC) User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (NetBSD/6.1.5 (i386)) Xref: csiph.com comp.lang.postscript:2725 luser droog wrote: > On Wednesday, August 3, 2016 at 12:20:34 AM UTC-5, luser droog wrote: >> On Tuesday, August 2, 2016 at 11:58:10 PM UTC-5, luser droog wrote: >> > > > Earlier revisions are less "golfed" and easier to read: >> > > > http://codegolf.stackexchange.com/revisions/71388/1 >> > >> > #!/bin/bash >> > filename=$1 >> > toptext=$2 >> > bottext=$3 >> > >> > dims=`identify $filename | cut -d' ' -f3` >> > dimx=`echo $dims | cut -d'x' -f1` >> > dimy=`echo $dims | cut -d'x' -f2` >> > convert $filename $filename.eps >> > gs -q -g"$dims" -o $filename.png -sDEVICE=png48 -c " >> > /oldshowpage /showpage load def /showpage {} def >> > ($filename.eps)run matrix defaultmatrix setmatrix >> > /Helvetica-Bold 22 selectfont >> > /ceshow { >> > dup stringwidth pop neg 2 div 0 rmoveto >> > dup gsave 1 setgray show grestore >> > 0 setgray false charpath stroke >> > } def >> > $dimx 2 div $dimy 42 sub moveto ($toptext) ceshow >> > $dimx 2 div 8 moveto ($bottext) ceshow >> > oldshowpage " >> > >> > echo Your meme is ready in $filename.png >> > >> > Stupid MS Edge won't let me save the image. So while firing >> > up X, let me quote the readable version and offer my first >> > guess that the black and white image produces a different >> > number of words from `identify` and so the dims are not >> > found in field 3. >> >> Weird. That isn't the problem at all. The eps is getting a >> smaller sized version. >> >> josh@LAPTOP-ILO10OOF ~/meme >> $ identify duckrabbit.jpg >> duckrabbit.jpg JPEG 519x350 519x350+0+0 8-bit sRGB 39.3KB 0.031u 0:00.027 >> >> josh@LAPTOP-ILO10OOF ~/meme >> $ grep BoundingBox duckrabbit.jpg.eps >> %%BoundingBox: -0 -0 187 126 >> %%HiResBoundingBox: 0 0 186.84 126 >> %%PageBoundingBox: 0 0 187 126 >> >> If the script were to get the dims with something like >> >> convert $1 $1.eps >> dims=`grep %%BoundingBox $1.eps` >> x=`echo $dims| cut -d' ' -f4` >> y=`echo $dims| cut -d' ' -f5` >> >> that should get the right numbers to gs. > > oops. that gets x and y but dims isn't the right format for the -g arg. Thanks for trying. I'll check back to see if you solve the problem, but, like I said, please don't try too hard. I imagine imagemagick or gimp or similar tool could do the job if I really needed it done. (One or the other of Mr.Duck or Mr.Rabbit is, however, quite depressed by the failure, though I can't quite tell which one.) -- John Forkosh ( mailto: j@f.com where j=john and f=forkosh )