Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

can we choose the Postscript Level ?

4 views
Skip to first unread message

maura.m...@gmail.com

unread,
Aug 17, 2006, 9:57:47 AM8/17/06
to
At the moment saving the canvas to a postscript file uses (by default)
Postscript Level 1 which generates a big file. Does Tcl allow for
choosing the postscript level ?
In order to reduce the size of saved images it is desirable to save
them to a Postscript Level 2 file.
How can I instruct Tcl to pick Level 2 instead of 1 ?
Thank you,
maura

Michael Schlenker

unread,
Aug 17, 2006, 10:21:41 AM8/17/06
to
maura.m...@gmail.com schrieb:

There is Postscript construction code inside the Tcl canvas C code,
which would have to be brought up to more modern standards to allow this
IIRC.

Michael

maura.m...@gmail.com

unread,
Aug 17, 2006, 11:48:58 AM8/17/06
to
Unluckily I'm not up to this task. But if someone is amenable to
provide me with some guidelines then I can try. Writing C code is
easier for me than writing Tcl procs.

Is there any other format that Tcl supports to save canvas images
(pdf, tiff, jpeg, etc...) ?
Thank you,
Maura

Michael Schlenker

unread,
Aug 17, 2006, 12:18:10 PM8/17/06
to
maura.m...@gmail.com schrieb:

> Unluckily I'm not up to this task. But if someone is amenable to
> provide me with some guidelines then I can try. Writing C code is
> easier for me than writing Tcl procs.

The code is in the Tk generic dir in the Tk source distribution
TkCanvasPs.c or something like it
(see:
http://tktoolkit.cvs.sourceforge.net/tktoolkit/tk/generic/tkCanvPs.c?view=markup
and
http://tktoolkit.cvs.sourceforge.net/tktoolkit/tk/generic/prolog.ps?view=markup
)


>
> Is there any other format that Tcl supports to save canvas images
> (pdf, tiff, jpeg, etc...) ?

Yes. The Img package has some support:
http://wiki.tcl.tk/Img

For PDF there is the trampoline package:
http://wiki.tcl.tk/13033

And see this page for Canvas to SVG code:
http://wiki.tcl.tk/4534

Michael

Ralf Fassel

unread,
Aug 17, 2006, 12:23:51 PM8/17/06
to
* "maura.m...@gmail.com" <maura.m...@gmail.com>

| Is there any other format that Tcl supports to save canvas images
| (pdf, tiff, jpeg, etc...) ?

You could try to postprocess the PostScript via ps2ps or pstops or
some other filter. But since in the case of image/photo objects in
the canvas most of the info will be bitmap style (?), I doubt that
there is much to gain...

R'

Cameron Laird

unread,
Aug 17, 2006, 12:44:41 PM8/17/06
to
In article <1155829738.3...@i42g2000cwa.googlegroups.com>,

maura.m...@gmail.com <maura.m...@gmail.com> wrote:
>Unluckily I'm not up to this task. But if someone is amenable to
>provide me with some guidelines then I can try. Writing C code is
>easier for me than writing Tcl procs.
>
>Is there any other format that Tcl supports to save canvas images
>(pdf, tiff, jpeg, etc...) ?
.
.
.
Not directly, no.

*Should* core Tcl emit PostScript Level 2? Can someone closer
to the action summarize the issue?

Donal K. Fellows

unread,
Aug 17, 2006, 5:32:19 PM8/17/06
to
Cameron Laird wrote:
> *Should* core Tcl emit PostScript Level 2? Can someone closer
> to the action summarize the issue?

As I understand it, everything that is in level 1 is OK in the other
higher levels. The only real reason for changing things would be if
there was some feature available in level 2 or 3 that we need for a
better rendering of the output. But I don't know enough about the
higher levels to know much about that; my own expertise is strictly at
the 'level 1' stage anyway.

Donal.

maura.m...@gmail.com

unread,
Aug 18, 2006, 1:04:15 AM8/18/06
to
The reason motivating my question is to get smaller files.
I went through the following two experiments:

Test #1
- save the canvas image to a Postscript file
- convert the eps file to pdf
- compress the eps file (gzip)
- compress the pdf file (gzip)

Now compare the respective sizes of the eps and pdf files (from 10s of
MB to some 100s of KB),
Compare the respective size of the eps and its compressed version
(eps.gz). You'll notice that gzip han sustantially cut down the
original eps size.
Now compare the size of the pdf file with its compressed version
(pdf.gz). You'll notice that the two sizes are comparable.
>From the above I infer that pdf is a pretty optimized format whereas
its eps counterpart contains a lot of useless data that gzip cuts off
based on an almost lossless information scheme.

Test #1
- load a sophisticated image with GIMP and save it to an eps level-1
file
- load the same image with GIMP and save it to an eps level-2 file
- print both files through a color printer (a good one)

Compare the respective size ... you'll realize how much disk space is
saved by savng to eps level-2.
Compare the two print-outs. You can hardly find any difference at all
!!!

Maura

Uwe Klein

unread,
Aug 18, 2006, 6:24:24 AM8/18/06
to
maura.m...@gmail.com wrote:
> The reason motivating my question is to get smaller files.
> I went through the following two experiments:
>
> Test #1
> - save the canvas image to a Postscript file
> - convert the eps file to pdf
> - compress the eps file (gzip)
> - compress the pdf file (gzip)

pdf already provides (efficient) compression for content.

Postscript level 2 introduced the ability to handle compressed data.

< quote from http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf >
2.2.2 Compression
To reduce file size, PDF supports a number of industry-standard compression
filters:
• JPEG and (in PDF 1.5) JPEG2000 compression of color and grayscale images
• CCITT (Group 3 or Group 4), run-length, and (in PDF 1.4) JBIG2 compres-
sion of monochrome images
• LZW (Lempel-Ziv-Welch) and (beginning with PDF 1.2) Flate compression of
text, graphics, and images
Using JPEG compression, color and grayscale images can be compressed by a fac-
tor of 10 or more. Effective compression of monochrome images depends on the
compression filter used and the properties of the image, but reductions of 2:1 to
8:1 are common (or 20:1 to 50:1 for JBIG2 compression of an image of a page full
of text). LZW or Flate compression of the content streams describing all other
text and graphics in the document results in compression ratios of approximately
2:1. All of these compression filters produce binary data, which can be further
converted to ASCII base-85 encoding if a 7-bit ASCII representation is required.
</quote>

found on http://partners.adobe.com/public/developer/pdf/index_reference.html

uwe

0 new messages