r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Postscript] Emitting Postscript from REBOL

Henrik
23-Feb-2008
[1373]
And I also badly need bitmap support :-)
Geomol
23-Feb-2008
[1374]
Ok, I try to stick to the standard and keep things simple.
Henrik
23-Feb-2008
[1375]
well, I tried standard commands, but it seems that printers and postscript 
is like HTML and webbrowsers, unfortunately.
Geomol
23-Feb-2008
[1376]
damn
Henrik
23-Feb-2008
[1377]
it would be wise to look at demo postscript files from around the 
net and see what they do. try to print them on various printers.
Geomol
23-Feb-2008
[1378]
When you had problem, did you try changing the %%Pages and %%Page 
lines in the ps-doc?
Henrik
23-Feb-2008
[1379]
had very limited time to test and don't remember
Geomol
23-Feb-2008
[1380]
ok
Henrik
23-Feb-2008
[1381x2]
it was a panic situation .:-)
furthermore, when printing with LP under OSX, produces different 
margins and scales than LP under Linux. so that's fun.
Geomol
23-Feb-2008
[1383x2]
Added PageSize and images to the PostScript dialect. There seem to 
be a problem with jpg!?
Henrik, try this:

do http://home.tiscali.dk/john.niclasen/postscript/postscript.r

write %imagetest.ps postscript [page [translate 100 600 scale 72 
72 image logo.gif translate 100 500 scale 144 144 image logo.gif 
translate 100 300 scale 288 288 image logo.gif]]

Then view or print the file imagetest.ps
This gives a result, that I can't view on my Mac for some reason:


write %imagetest.ps postscript [page [translate 100 400 scale 72 
72 image http://www.rebol.com/view/palms.jpg]]

Any suggestions?
Henrik
23-Feb-2008
[1385x4]
preview.app is unfortunately also half demented :-(
ghostscript is better to reference against
and I can't test right now as I don't have the printer set up
I will test as soon as possible
Geomol
23-Feb-2008
[1389]
I have problem viewing the test with jpg here. It can't convert it 
to a viewing format (prob. PDF). Can you test the ghostscript viewer?
Henrik
23-Feb-2008
[1390]
will take 30 mins to set up. hang on.
Geomol
23-Feb-2008
[1391]
Documentation is here:
http://home.tiscali.dk/john.niclasen/postscript/postscript.html
Henrik
23-Feb-2008
[1392]
any image formats that you've tested that works?
Geomol
23-Feb-2008
[1393]
gif and bmp
Henrik
23-Feb-2008
[1394]
so it converts it to image! before feeding it to postscript dialect?
Geomol
23-Feb-2008
[1395]
Hm, maybe it has something to do with the size of the image. I saved 
logo.gif as %logo.bmp and it works. If I save that palms.jpg as %palms.bmp, 
it doesn't work.
Henrik
23-Feb-2008
[1396]
afk, 30 mins
Geomol
23-Feb-2008
[1397x2]
Yes, images are handled as REBOL image! types. If the dialect is 
given a file! or url!, it'll load the image. It can also take a word!, 
which is the image. It then convert the image/rgb to base-16 and 
put it in the ps-file.
So images in postscript files take up a lot of space! Most people 
knows this already. I tried to put a 100k png image in a postscript 
file, and it then was > 11MB.
Henrik
23-Feb-2008
[1399x2]
wow
what about 2-colored GIFs?
Graham
23-Feb-2008
[1401]
I"ve always converted images to eps before including them. Never 
used raw image data.
BrianH
23-Feb-2008
[1402]
That will work with vector images, but not necessarily pictures - 
EPS would have the same problems as Postscript.
Henrik
23-Feb-2008
[1403]
AFAIK, EPS is PS without page handling information
Graham
23-Feb-2008
[1404x2]
Yes. I use things like imagemagick to do the conversion for me from 
binary image ( whatever format ) to eps.
But if the image is big, it remains big ... not that it's a problem 
because it's being dumped to a printer.
Henrik
23-Feb-2008
[1406]
it's a problem for speed, but perhaps there really is no way around 
it
Graham
23-Feb-2008
[1407]
exactly because postscript can not handle gif, tiff, png, jpeg etc.
Henrik
23-Feb-2008
[1408]
but I was wondering if it accepts some kind of 2 or 4 bit format 
for smaller data sizes. the images I need to use are usually of low 
color.
Graham
23-Feb-2008
[1409]
whereas LaTeX can use jpeg.
Henrik
23-Feb-2008
[1410]
well, LaTeX is converted to postscript, so maybe the end result is 
the same.
Graham
23-Feb-2008
[1411]
Here's an article on coverting a jpeg to image using postscript functions 
http://www.tinaja.com/glib/jpg2pdf.pdf
Geomol
23-Feb-2008
[1412x2]
This with large printfiles, it's the same, that happens, if you print 
text using a font, that the printer doesn't know. Everything is converted 
to image data, and one page can be several MB.
The image problem seems to be related to size. I tried to make a 
little image entirely in REBOL, and I can see that. Making a larger 
image, and Preview under OSX can't convert it to PDF. I would like 
to know, if my example above with palms.jpg can be printed on paper.
BrianH
23-Feb-2008
[1414]
If the image is 11mb, the printer would need more memory than that 
to print it, assuming the Postscript has no logic bugs that would 
prevent the printer from rendering the image at all.
Geomol
23-Feb-2008
[1415]
I have problem with an image like in this example:

do http://home.tiscali.dk/john.niclasen/postscript/postscript.r
img: to-image layout [box 20x20 red box blue]

write %imagetest.ps postscript [page [translate 100 400 scale 72 
72 image img]]


Try print (or view) the imagetest.ps file. Do you also get an error?
Henrik
23-Feb-2008
[1416x3]
ERROR: /rangecheckESP Ghostscript 815.04: Unrecoverable error, exit 
code 1
 in --string--
Operand stack:
   picstr   70560
Execution stack:

   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-- 
     2   %stopped_push   --nostringval--   --nostringval--   --nostringval-- 
     false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop 
     1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval-- 
     --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:

   --dict:1125/1686(ro)(G)--   --dict:0/20(G)--   --dict:108/200(L)--
Current allocation mode is local
That's what I get
Geomol, I wonder if GS can output it's stacks for debugging purposes. 
would that be useful to you?
Graham
23-Feb-2008
[1419]
Since postscript is a printer language, it can print the stacks if 
it encounters an error.
Henrik
23-Feb-2008
[1420]
then I suppose it's enough to use the ghostscript console
Graham
23-Feb-2008
[1421]
sure if you're using ghostscript .. I meant if you were testing on 
a postscript printer.
Henrik
23-Feb-2008
[1422]
I think it's easier to debug it in ghostscript. The printers I've 
tried this on will not print stack information. Perhaps only if I 
dive really deep into the capabilities of the printer, which I have 
no time for.