Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1127 > unrolled thread

Putting lines from a file into an array

Started byCecil Westerhof <Cecil@decebal.nl>
First post2012-12-02 21:02 +0100
Last post2016-08-22 22:31 -0700
Articles 4 on this page of 24 — 8 participants

Back to article view | Back to comp.lang.postscript


Contents

  Putting lines from a file into an array Cecil Westerhof <Cecil@decebal.nl> - 2012-12-02 21:02 +0100
    Re: Putting lines from a file into an array Chris <cjl@spamcop.net> - 2012-12-02 20:47 +0000
      Re: Putting lines from a file into an array Cecil Westerhof <Cecil@decebal.nl> - 2012-12-03 00:52 +0100
        Re: Putting lines from a file into an array Don Lancaster <don@tinaja.com> - 2012-12-05 11:58 -0700
          Re: Putting lines from a file into an array "luser.droog" <luser.droog@gmail.com> - 2012-12-05 23:19 -0600
      Re: Putting lines from a file into an array John Deubert <john@acumentraining.com> - 2012-12-03 13:20 -0800
        Re: Putting lines from a file into an array "luser.droog" <luser.droog@gmail.com> - 2012-12-04 00:58 -0600
        Re: Putting lines from a file into an array Chris <cjl@spamcop.net> - 2012-12-04 09:09 +0000
          Re: Putting lines from a file into an array John Deubert <john@acumentraining.com> - 2012-12-04 07:03 -0800
            Re: Putting lines from a file into an array Chris <cjl@spamcop.net> - 2012-12-04 17:46 +0000
          Re: Putting lines from a file into an array Cecil Westerhof <Cecil@decebal.nl> - 2012-12-04 17:17 +0100
    Re: Putting lines from a file into an array "luser.droog" <luser.droog@gmail.com> - 2012-12-02 15:31 -0600
      Re: Putting lines from a file into an array Cecil Westerhof <Cecil@decebal.nl> - 2012-12-03 02:19 +0100
        Re: Putting lines from a file into an array "luser.droog" <luser.droog@gmail.com> - 2012-12-02 23:28 -0600
          Re: Putting lines from a file into an array Cecil Westerhof <Cecil@decebal.nl> - 2012-12-03 10:01 +0100
    Re: Putting lines from a file into an array luser droog <luser.droog@gmail.com> - 2016-08-01 13:25 -0700
      Re: Putting lines from a file into an array JohnF <john@please.see.sig.for.email.com> - 2016-08-02 03:39 +0000
        Re: Putting lines from a file into an array luser droog <luser.droog@gmail.com> - 2016-08-02 21:58 -0700
          Re: Putting lines from a file into an array Tonton Th <tTh@nowhere.invalid> - 2016-08-03 05:10 +0000
          Re: Putting lines from a file into an array luser droog <luser.droog@gmail.com> - 2016-08-02 22:20 -0700
            Re: Putting lines from a file into an array luser droog <luser.droog@gmail.com> - 2016-08-02 22:35 -0700
              Re: Putting lines from a file into an array JohnF <john@please.see.sig.for.email.com> - 2016-08-03 06:21 +0000
              Re: Putting lines from a file into an array JohnF <john@please.see.sig.for.email.com> - 2016-08-03 06:32 +0000
                Re: Putting lines from a file into an array luser droog <luser.droog@gmail.com> - 2016-08-22 22:31 -0700

Page 2 of 2 — ← Prev page 1 [2]


#2724

Fromluser droog <luser.droog@gmail.com>
Date2016-08-02 22:35 -0700
Message-ID<8b56c6b3-1d1d-47d2-aa00-32deffb3fc7c@googlegroups.com>
In reply to#2723
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.

[toc] | [prev] | [next] | [standalone]


#2725

FromJohnF <john@please.see.sig.for.email.com>
Date2016-08-03 06:21 +0000
Message-ID<nns2hm$4qp$1@reader2.panix.com>
In reply to#2724
luser droog <luser.droog@gmail.com> 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 )

[toc] | [prev] | [next] | [standalone]


#2726

FromJohnF <john@please.see.sig.for.email.com>
Date2016-08-03 06:32 +0000
Message-ID<nns359$4qp$2@reader2.panix.com>
In reply to#2724
luser droog <luser.droog@gmail.com> wrote:
> <<snip>>
> oops. that gets x and y but dims isn't the right format for the -g arg.

I semi-solved the problem, or, rather, side-stepped it.
I just ran  xv duckrabbit.jpg  and immediately used xv to save
it as "full color". Then ran meme.sh against that, and it worked
out fine. Could you maybe easily check in meme.sh whether or not
you're given a color image to begin with, and add in a similar
step if needed?
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

[toc] | [prev] | [next] | [standalone]


#2789

Fromluser droog <luser.droog@gmail.com>
Date2016-08-22 22:31 -0700
Message-ID<8a8d3d7e-b8a4-432b-8a4c-f7ec69ff126d@googlegroups.com>
In reply to#2726
On Wednesday, August 3, 2016 at 1:32:10 AM UTC-5, JohnF wrote:
> luser droog <luser.droog@gmail.com> wrote:
> > <<snip>>
> > oops. that gets x and y but dims isn't the right format for the -g arg.
> 
> I semi-solved the problem, or, rather, side-stepped it.
> I just ran  xv duckrabbit.jpg  and immediately used xv to save
> it as "full color". Then ran meme.sh against that, and it worked
> out fine. Could you maybe easily check in meme.sh whether or not
> you're given a color image to begin with, and add in a similar
> step if needed?

That could work. What I was thinking was to side-step
by converting first, then getting the dims from the eps,
whatever the resulting size ended up being.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.postscript


csiph-web