ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* %%BoundingBox: (atend)
@ 2004-05-30 12:24 Peter Münster
  2004-06-01 18:35 ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Münster @ 2004-05-30 12:24 UTC (permalink / raw)


Hello,
ConTeXt does not find the EPS-BoundingBox in EPS files generated by xmgrace.
Such a file begins like this:

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: (atend)

and it ends like this:

%%Trailer
%%BoundingBox: 64 72 709 527
%%DocumentNeededResources: font Times-Roman
%%EOF

When using \externalfigure, one gets the following error:
ERROR: Missing number, treated as zero.

--- TeX said ---
<to be read again> 
                   (
\EPSllx ->(
           atend)
\dogetEPSboundingbox ...m \EPSfound >0 #2=\EPSllx 
                                                  bp#4=\EPSurx bp#3=\EPSlly ...

Would it be possible, to enable ConTeXt to read such a file?
If not, I'm going to write a script, that converts the file.

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
_____________________________________
FilmSearch engine: http://f-s.sf.net/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: %%BoundingBox: (atend)
  2004-05-30 12:24 %%BoundingBox: (atend) Peter Münster
@ 2004-06-01 18:35 ` Hans Hagen
  2004-06-02 13:13   ` George N. White III
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2004-06-01 18:35 UTC (permalink / raw)


At 14:24 30/05/2004, you wrote:
>Hello,
>ConTeXt does not find the EPS-BoundingBox in EPS files generated by xmgrace.
>Such a file begins like this:
>
>%!PS-Adobe-3.0 EPSF-3.0
>%%BoundingBox: (atend)
>
>and it ends like this:
>
>%%Trailer
>%%BoundingBox: 64 72 709 527
>%%DocumentNeededResources: font Times-Roman
>%%EOF
>
>When using \externalfigure, one gets the following error:
>ERROR: Missing number, treated as zero.
>
>--- TeX said ---
><to be read again>
>                    (
>\EPSllx ->(
>            atend)
>\dogetEPSboundingbox ...m \EPSfound >0 #2=\EPSllx
>                                                   bp#4=\EPSurx 
> bp#3=\EPSlly ...
>
>Would it be possible, to enable ConTeXt to read such a file?

sure but it could mess up things as well, esp since there can be a couple 
of (binary) megabytes in between

>If not, I'm going to write a script, that converts the file.

if you have a small demo file i can add that feature to texutil

Hans  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: %%BoundingBox: (atend)
  2004-06-01 18:35 ` Hans Hagen
@ 2004-06-02 13:13   ` George N. White III
  2004-06-02 13:46     ` Taco Hoekwater
  0 siblings, 1 reply; 7+ messages in thread
From: George N. White III @ 2004-06-02 13:13 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 1038 bytes --]

On Tue, 1 Jun 2004, Hans Hagen wrote:

> At 14:24 30/05/2004, you wrote:
>> Hello,
>> ConTeXt does not find the EPS-BoundingBox in EPS files generated by 
>> xmgrace.
>> Such a file begins like this:
>> 
>> %!PS-Adobe-3.0 EPSF-3.0
>> %%BoundingBox: (atend)
> [...]
>> If not, I'm going to write a script, that converts the file.
>
> if you have a small demo file i can add that feature to texutil

I'd suggest adopting some of the conventions used by the
LaTeX2e graphics bundle, in particular, to look for the 
BoundingBox in filename.(e)ps.bb.

Rather than making texutil more complex a separate tool (findbb, attached)
that reliably writes the bbox by trying several methods, even using the 
ghostscript bbox device to generate one (e.g., in the case of files 
created with dvips -E that get incorrect BoundingBox entries because the 
dvips calculation ignores things drawn by \specials).

Try "findbb xmgracefile.ps > xmgracefile.ps.bb"

--
George N. White III  <aa056@chebucto.ns.ca>
   Head of St. Margarets Bay, Nova Scotia, Canada

[-- Attachment #2: unix ksh script (should work with bash) to find BoundingBox --]
[-- Type: TEXT/PLAIN, Size: 2434 bytes --]

#! /bin/ksh
# findbb -- write PostScript BoundingBox to stdout

# Notes:

# 0. The '-b' flag can be used with .pdf files.

# 1. (e)ps files may contain binary preview images and may
#    use non-native newlines, so must be handled as binary.  
#    Our approach is to grab the first 5000 bytes
#    of the file, then convert \012 and \015 to \012 for
#    processing with tools intended for use with text files.

# 2. if the file does not provide a BoundingBox line, use
#    the GhostScript bbox device (-b flag) to generate one.

# 3. if the first entry is %%BoundingBox: (atend), examine
#    the last 5000 bytes of the file

# Bugs:
#    Does not normalize the line by adding a space after the ':'
#    Does not handle large preview images

# Author: George N. White III <aa056@chebucto.ns.ca>
#     

pgm="$(basename $0)"
usage="usage: $pgm [-b] filename"

TMPDIR=${TMPDIR:-/usr/tmp}
GS_PROG=${GS_PROG:-gsc} 

tempnm=$(mktemp $TMPDIR/$pgm-temp.XXXXXXXXXX ) || exit 1
pipenm=$(mktemp $TMPDIR/$pgm-pipe.XXXXXXXXXX ) || exit 1
/sbin/rm -f "$pipenm" && /sbin/mknod "$pipenm" p

trap "rm -f $tempnm $pipenm ; exit \$rc" 0

flags=""
case $# in
2) case $1 in
   -b) flags="b$flags" ; shift
       ;;
    *) print -u2 $usage ; exit 1
       ;;
    esac
    ;;
1)  ;;
*)  print -u2 $usage ; exit 1
    ;;
esac

# can we read the file?
if [ -r "$1" ] ; then
    fnm="$1"
else
    print -u2 "$pgm: unable to read file <$1>."
    exit 1
fi

case $flags in
*b*) $GS_PROG -q -dBATCH -dNOPAUSE -sDEVICE=bbox $fnm > $tempnm 2>&1 
     set $(grep --max-count=1 '^%%BoundingBox:' $tempnm ) || exit 1
     ;;
*)   set $(head --bytes=5000 $fnm | tr '[\012\015]' '\012' | grep --max-count=1 '^%%BoundingBox:') || exit 1
     ;;
esac

case "$#" in
1|2) # handle '^%%BoundingBox:(atend)' and '^%%BoundingBox: (atend)'
   case "$1$2" in
   %%BoundingBox:\(atend\)) print -u2 "$pgm -- looking 'atend'"
       bbox=$(tail --bytes=5000 $fnm | tr '[\012\015]' '\012' \
            | grep '^%%BoundingBox:'|tail -1)
       ;;
   *)
       print -u2 "$pgm failed to find BoundingBox" ; exit 1
       ;;
   esac
   ;;
4|5) # handle BoundingBox:NN ... and BoundingBox: NN ...
   case "$1$2" in
   %%BoundingBox:*)   bbox="$@"
       ;;
   *)
       ;;
   esac
   ;;
*) print -u2 "$pgm failed to find BoundingBox, try setting '-b' flag." ; exit 1
   
esac
print "$bbox"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: %%BoundingBox: (atend)
  2004-06-02 13:13   ` George N. White III
@ 2004-06-02 13:46     ` Taco Hoekwater
  2004-06-02 18:13       ` Peter Münster
  0 siblings, 1 reply; 7+ messages in thread
From: Taco Hoekwater @ 2004-06-02 13:46 UTC (permalink / raw)



Hi,

A one-line patch to texutil.pl is enough to handle most cases of (atend).
The method is far from waterproof,  but neither is a Korn Shell script,
and the added complexity to texutil.pl is neglible.

Greetings, Taco

--- texutil.pl.org      2004-06-02 15:36:03.610266871 +0200
+++ texutil.pl  2004-06-02 15:38:17.454329753 +0200
@@ -2129,7 +2129,7 @@
                if (($BBoxFound) && ((substr $SomeLine,0,1) ne "%"))
                  { last }
                if ($BBoxFound<2)
-                 { if ($SomeLine =~ /^%%BoundingBox:/io)
+                 { if ($SomeLine =~ /^%%BoundingBox:(?!\s+\(atend\))/io)
                      { $EpsBBox = $SomeLine ; $BBoxFound = 1 ; next }
                    elsif ($SomeLine =~ /^%%HiResBoundingBox:/io)
                      { $EpsBBox = $SomeLine ; $BBoxFound = 2 ; next }


On Wed, 02 Jun 2004 10:13:33 -0300, George wrote:
> On Tue, 1 Jun 2004, Hans Hagen wrote:
> 
> > At 14:24 30/05/2004, you wrote:
> >> Hello,
> >> ConTeXt does not find the EPS-BoundingBox in EPS files generated by 
> >> xmgrace.
> >> Such a file begins like this:
> >> 
> >> %!PS-Adobe-3.0 EPSF-3.0
> >> %%BoundingBox: (atend)
> > [...]
> >> If not, I'm going to write a script, that converts the file.
> >
> > if you have a small demo file i can add that feature to texutil
> 
> I'd suggest adopting some of the conventions used by the
> LaTeX2e graphics bundle, in particular, to look for the 
> BoundingBox in filename.(e)ps.bb.
> 
> Rather than making texutil more complex a separate tool (findbb, attached)
> that reliably writes the bbox by trying several methods, even using the 
> ghostscript bbox device to generate one (e.g., in the case of files 
> created with dvips -E that get incorrect BoundingBox entries because the 
> dvips calculation ignores things drawn by \specials).
> 
> Try "findbb xmgracefile.ps > xmgracefile.ps.bb"
> 
> --
> George N. White III  <aa056@chebucto.ns.ca>
>    Head of St. Margarets Bay, Nova Scotia, Canada


-- 
groeten,

Taco

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: %%BoundingBox: (atend)
  2004-06-02 13:46     ` Taco Hoekwater
@ 2004-06-02 18:13       ` Peter Münster
  2004-06-03  7:50         ` Taco Hoekwater
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Münster @ 2004-06-02 18:13 UTC (permalink / raw)


On Wed, 2 Jun 2004, Taco Hoekwater wrote:

> +                 { if ($SomeLine =~ /^%%BoundingBox:(?!\s+\(atend\))/io)

Yes, this seems to be good.

But how is texutil used in this situation?

I've tried "texexec test" and "texexec --texutil test", but texutil is
never called.
test.tex is a file with a \externalfigure[image] command.

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
_____________________________________
FilmSearch engine: http://f-s.sf.net/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: %%BoundingBox: (atend)
  2004-06-02 18:13       ` Peter Münster
@ 2004-06-03  7:50         ` Taco Hoekwater
  2004-06-03 16:52           ` Peter Münster
  0 siblings, 1 reply; 7+ messages in thread
From: Taco Hoekwater @ 2004-06-03  7:50 UTC (permalink / raw)


On Wed, 2 Jun 2004 20:13:10 +0200 (CEST), Peter wrote:

> On Wed, 2 Jun 2004, Taco Hoekwater wrote:
> 
> > +                 { if ($SomeLine =~ /^%%BoundingBox:(?!\s+\(atend\))/io)
> 
> Yes, this seems to be good.
> 
> But how is texutil used in this situation?

with 
	texutil --figures

greetings,

Taco

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: %%BoundingBox: (atend)
  2004-06-03  7:50         ` Taco Hoekwater
@ 2004-06-03 16:52           ` Peter Münster
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Münster @ 2004-06-03 16:52 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 994 bytes --]

On Thu, 3 Jun 2004, Taco Hoekwater wrote:

> > But how is texutil used in this situation?
> 
> with 
> 	texutil --figures

I tried this too, but still the same error. Perhaps something wrong with my
installation? I would be glad if someone could help.
The file example.eps is in the attachment.
Here is test.tex:
\starttext
\externalfigure[example][width=10cm]
\stoptext

After executing "texutil --figures example.eps" the file texutil.tuf is
created:
%
% TeXUtil 8.2 - ConTeXt / PRAGMA ADE 1992-2004 / Figures
%
\thisisfigureversion{1996.06.01}
%
\presetfigure[example.eps][e=eps,w=22.754cm,h=16.051cm
,x=2.258cm,y=2.540cm,t={Untitled},c={Grace-5.1.14},s=9396]

And then, after "texexec test" the attached log-file is created.

I tried to move away the eps-file just before executing texexec and move it
back just before dvips, but then, I get a corrupted ps-file.

Greetings, Peter

-- 
http://pmrb.free.fr/contact/
_____________________________________
FilmSearch engine: http://f-s.sf.net/

[-- Attachment #2: eps-file --]
[-- Type: APPLICATION/postscript, Size: 9396 bytes --]

[-- Attachment #3: log-file --]
[-- Type: TEXT/PLAIN, Size: 2652 bytes --]

This is pdfeTeX, Version 3.14159-1.10b-2.1 (Web2C 7.4.5) (format=cont-en 2004.6.2)  3 JUN 2004 18:42
entering extended mode
**&cont-en test.tex
(./test.tex{/var/lib/texmf/pdftex/config/pdftex.cfg}

ConTeXt  ver: 2004.4.9  fmt: 2004.6.2  int: english  mes: english

language       : language en is active
<protectionstate 0>
system         : cont-new loaded
(/usr/share/texmf/tex/context/base/cont-new.tex
systems        : beware: some patches loaded from cont-new.tex!
color          : palette rollover is available
system (E-TEX) : [line 278] 
system (E-TEX) : [line 333] 
)
system         : cont-old loaded
(/usr/share/texmf/tex/context/base/cont-old.tex
loading        : Context Old Macros
)
system         : cont-fil loaded
(/usr/share/texmf/tex/context/base/cont-fil.tex
loading        : Context File Synonyms
)
system         : cont-sys loaded
(/var/lib/texmf/tex/context/config/cont-sys.tex)
system         : macros of module tryout loaded
(/usr/share/texmf/tex/context/base/m-tryout.tex
\openout2 = `test.tui'.

)
bodyfont       : 12pt rm is loaded
language       : patterns 2:2-en-2 3:2-uk-2 4:2-de-2 5:2-fr-2 6:2-es-2 7:2-it-2
 8:2-nl-2 loaded
specials       : tex,postscript,rokicki loaded
\openout2 = `test.tui'.

system         : test.top loaded
(./test.top)
\openout0 = `test-mpgraph.mp'.

\openout0 = `mpgraph.mp'.


fonts          : needs map file: ec-public-lm.map
fonts          : needs map file: original-base.map
systems        : begin file test at line 1
! Missing number, treated as zero.
<to be read again> 
                   (
\EPSllx ->(
           atend)
\dogetEPSboundingbox ...m \EPSfound >0 #2=\EPSllx 
                                                  bp#4=\EPSurx bp#3=\EPSlly ...

\getfiguredimensionsA ...heightb } \executedfalse 
                                                  \ifexecuted \donetrue \ifd...
<argument> \getfiguredimensionsA 
                                 \getfiguredimensionsB \getfiguredimensionsC 
\firstoftwoarguments #1#2->#1
                             
...
l.3 \stoptext
             
? x
 
Here is how much of TeX's memory you used:
 888 strings out of 66597
 9826 string characters out of 727591
 4409401 words of memory out of 5504447
 32118 multiletter control sequences out of 10000+50000
 10284 words of font info for 34 fonts, out of 500000 for 1000
 62 hyphenation exceptions out of 1000
 27i,1n,40p,149b,714s stack positions out of 1500i,500n,5000p,200000b,5000s
 0 PDF objects out of 300000
 0 named destinations out of 131072
 0 words of extra memory for PDF output out of 65536
No pages of output.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-06-03 16:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-30 12:24 %%BoundingBox: (atend) Peter Münster
2004-06-01 18:35 ` Hans Hagen
2004-06-02 13:13   ` George N. White III
2004-06-02 13:46     ` Taco Hoekwater
2004-06-02 18:13       ` Peter Münster
2004-06-03  7:50         ` Taco Hoekwater
2004-06-03 16:52           ` Peter Münster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).