🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.postscript.programming
Article #5

Re: Adding a jpeg to a postscript file

#5
From: Miklos_Somogyi
Date: Fri, 02 Jan 2009 21:52
87 lines
4354 bytes
Eric,

There are a few separate issues here.

-----------

Getting the eps file into your PS depends on your operating system.
I use a Mac that is Unix based, so I get my PS into the `vi' editor, go to the place where
I want the eps, then issue a `:r <filename>' instruction to read it in.
If I want the eps at the end of the PS, I can use the `cat' command to concatenate PS and eps and place the result in a third file.
There must be some equivalents in case you use a PC.

If you don't want to copy the (presumably big) image into your PS, just write in the PS at the appropriate place:

`(filename) run'

This leaves the eps file where it is for future viewing, and prints where you want it
printed without duplicating the eps.

------------

Where to place the image? You are on a good path with reading the eps manual and
probably someone else can help you here.
I usually do more than printing an eps as it is (e.g. clippingi, drawing borders or not,
adjust images to have the same width or height in print, etc), so I only use eps to give
me the image's essentials, then use the PS operator `image'.

If you use Acrobat for conversion, it produces a huge file header from which I've never had the patience to extract the essentials.
I rather use GraphicConverter for the conversion that gives me a file like this:

%!PS-Adobe-3.0 EPSF-3.0
%%Creator: GraphicConverter V6.1.2 X PowerPC (CFM)
%%Title: DSC00151-gc.eps
%%CreationDate: 2009-01-03
%%Pages: 1
%%BoundingBox: 0 0 3264 2448
%%DocumentData: Clean7Bit
%%EndComments
%%BeginProlog
%%EndProlog
%%Page: 1 1
%ImageData: 3264 2448 8 3 0 9792 2 } exec
/languagelevel where {pop languagelevel 2 lt} {true} ifelse {
 (JPEG picture requires Postscript level 2
) dup print flush
 /Helvetica findfont 20 scalefont setfont 100 100 moveto show showpage stop
} if
save
/RawData currentfile /ASCIIHexDecode filter def
/Data RawData << >> /DCTDecode filter def
3264.00 2448.00 scale
/DeviceRGB setcolorspace
{ << /ImageType 1 /Width 3264 /Height 2448 /ImageMatrix [ 3264 0 0 -2448 0 2448 ] /DataSource Data /BitsPerComponent 8 /Decode [0 1 0 1 0 1] >> image
 Data closefile
 RawData flushfile
 showpage
 restore
} exec
FFD8FFE000104A46494600010101004800480000FFFE000C4170706C654D61
726B0AFFDB0084000302020202020302020203030303040604040404040705
      :
      :
C103BDBDCC81E7C6006E411F5F5AE9A54DB4D221AD7DDDCFFFD9>
%%EOF

This header is reasonably small and clear, it tells you that the image is colour images, its width and height are ... and ..., that it has two filters.
That's enough to construct my own dictionary for the image operator, using my own scaling and translation.

Better still, you may write a routine that takes GC's output as it is, reads the header
until it finds its end, extracts Width and Height, etc, and construct the new dictionary.
Then it uses GC's image data to paint the picture where you want it printed.
This way you have your eps file intact, and you have your picture as well.

This routine needs to be written once, then your PS file needs to contain only 2 lines
of extra code:

x1 y1 x2 y2 ... maybe some other parameters ... your-routine's-name
(epsfile'sname) run

Here x1 y1 x2 y2 are the coordinates of the image's viewport on paper, possibly in millimetres.

All this needs a bit of learning and experimenting. If your problem is once-only, then
it is not worth the effort, and the best thing is to use the eps file as eps files were
originally intended to be used. That would need to read a page or two.
If you need to do more than placing an image into a viewport and you need to do this many times, then it pays to invest in your own image handling routine.

Miklos
Technical Details
Message-ID: <59b76798.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b76798.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10c61a,6c91da5fbb73e921
X-Google-Attributes: gid10c61a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Miklos_Somogyi@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.postscript.programming
Subject: Re: Adding a jpeg to a postscript file
Message-ID: <59b76798.4@webcrossing.la2eafNXanI>
Date: Fri, 2 Jan 2009 13:52:41 -0800
References: <59b76798.-1@webcrossing.la2eafNXanI>
Lines: 117
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit