[techtalk] A Postscript question

Helena Verrill verrill at math.ku.dk
Thu Jul 13 22:42:17 EST 2000


Well, I've done a little postscript programing in the past
(it's a fun language to program in directly, but usually more
practical to write c programs to produce postscript output).
I never tried editing an image before, but I just had a go 
at your question,  because I wanted to know what the answer is.  
Here is what I came up with for now:

I converted a .jpg file to a ps file using xv.
Then, looked in the file for somewhere where it says
"scale", In the postscript file I have, there are two lines
that say:

% size of image (on paper, in 1/72inch coords)
319.96800 239.97600 scale

Then there is some stuff to define how to draw the image as a 
bitmap (or something like that) etc.
Anyway, near the end of the file, after all the stuff for the image,
and just before the line where it says "showpage", I inserted the
following 4 lines:

0.003125  0.004167 scale
/Helvetica-BoldOblique findfont 40 scalefont setfont
10 100 moveto
(SOME WORDS) show

The numbers  0.003125  and 0.004167 in the scaling are just got by
taking the reciprocals of the previous scaling used, so you get
back to one (ie, from the line "319.96800 239.97600 scale", you 
compute 1/319.96800 = 0.003125  and 1/239.97600 = 0.004167).  
You could probably also use a gsave and grestore commands too - I'd
have to think more about where to insert them though.

This produced a picture with the text "SOME WORDS" printed over
the picture at position (10,100), in Helvetica-BoldOblique, font
size 40.  You can use other fonts and other sizes, depending on
what's on your system.  You can change the (10 100) to move the
text around too.

There are probably alternative ways to get some text on the image,
and probably you don't want to bother with this as you have an
alternative solution now.  This solution might not be enough for
your purposes anyway.
If anyone with more expertise in postscript than me has
good suggestions for postscript improvements on the above 
I'd be interested to hear them too.

There are several nice resources on the
web with lists of commands for writing in postscript, eg, see
http://www.cs.indiana.edu/docproject/programming/postscript/operators.html
for a list of operators, which does not give all possible operators
but seems a good place to start.  
(postscript works with a stack - it's kind of like German or Japanese,
with the verb at the end, eg "10 10 moveto" means "moveto 10 10")
You could experiment, if you want.
(Well, I know you don't need to now, but in case you're curious.)

Helena

---------------
On Thu, 13 Jul 2000, Amanda Owens wrote:

> Actually, that's what I ended up doing - using xfig. In a couple of
> different ways. But it looks to have turned out well in the end. The
> reason my boss wanted to do the postscript markup was so that when the
> image was scaled, the text would scale right along with it. 
> 
> Oh well. Popping the jpg into xfig and adding stuff worked like a dream.
> 
> Mur!
> 
> On Thu, 13 Jul 2000, T. E. Pickering wrote:
> 
> > imagemagick, gimp, and xv can all import .ps files as images, but the
> > catch is that they turn them into fixed resolution bitmaps.  the best
> > way to annotate .ps (.eps, actually, but that's what xv spits out so
> > you're cool) files is to use xfig.  it retains the full vector
> > information of the .ps file so you don't lose any resolution.  i use
> > it all the time to take .ps files of images and then add text and
> > arrows and stuff to label up the image.  it is, and has been for many
> > years, one of the very coolest unix programs around. 
> > 
> > tim
> 
> 
> 
> _______________________________________________
> techtalk mailing list
> techtalk at linuxchix.org
> http://www.linux.org.uk/mailman/listinfo/techtalk
> 









More information about the Techtalk mailing list