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

World: r3wp

[Postscript] Emitting Postscript from REBOL

Anton
14-Oct-2008
[1753]
(Never mind the save/bmp thing.)
Geomol
14-Oct-2008
[1754]
:-) Good to see some being done in this area. If you have ideas for 
the postscript dialect
http://home.tiscali.dk/john.niclasen/postscript/postscript.r
, let me know.


Documentation: http://home.tiscali.dk/john.niclasen/postscript/postscript.html
Anton
14-Oct-2008
[1755]
Ah docs by the author.. :)
Geomol
14-Oct-2008
[1756]
Yeah, that's rare, isn't it! ;P
Anton
14-Oct-2008
[1757x2]
write/binary %test-image.ps postscript [DeviceRGB [translate 10x10 
scale 72x72 image help.gif]]
I can see the help.gif image, in colour, at the bottom of the page, 
using kghostview.
Geomol
14-Oct-2008
[1759]
I can too using Preview under OS X.
Anton
14-Oct-2008
[1760]
Hmm.. what's the height of the page ?  I want to put the image at 
the top.
Geomol
14-Oct-2008
[1761x2]
Paper sizes in postscript:
A4: 595x842
A5: 420x595
Letter: 612x792
You can also use the command "switchy" to switch y-axis. See last 
command in the docs.
Anton
14-Oct-2008
[1763x2]
Aha, that's useful for what Henrik's doing.
I suppose actually I should ignore the page size.
Geomol
14-Oct-2008
[1765x3]
The whole page will be upside down, it seems, also the graphics. 
That can prob. be fixed with some transformation.
I think, if you write code, that'll produce postscript output, you 
have to know the paper size. At least the last step has to know. 
I see postscript as a language, where you have full control over, 
what you get on the paper.
In contrast to e.g. HTML, where it's up to the browser, how it'll 
look.
Anton
14-Oct-2008
[1768x10]
This talks about page size.
http://alumni.media.mit.edu/~szummer/postscript/
How to generate portable Postscript
Do not explicitly specify paper format. 
 Unfortunately, many programs 
force you to select a paper size. Often, it can be edited out of 
the Postscript file. Instead, let the printer decide whether it can 
print a document with specific dimensions.
It's an old document, from 2000, though...
I'm just wondering what the default page size is, when it's not specified.
pagesize: 595x842  ; Default A4 page size
img: help.gif
offset: 0x0

write/binary %test-image.ps postscript compose/deep [DeviceRGB [translate 
(as-pair offset/x pagesize/y - offset/y - img/size/y) scale 36x36 
image img]]
kghostview test-image.ps  shows the help.gif image just down a little 
bit from the top-left of the page. I suppose it's a margin of some 
sort.
Hmm.. if I have
	offset: pagesize - img/size

then it shows the image just a little left of bottom-right corner 
of page.
Another margin ?
Anyway... just a little dabble in the postscript world..
Henrik
14-Oct-2008
[1778x2]
the only problem with switchy is that everything is upside down, 
inclusing text.
Geomol, I've added direct support for image! in the postscript dialect. 
It seemed appropriate to do.
Geomol
14-Oct-2008
[1780]
Henrik, I can see, there's a bit difference in our versions. Maybe 
we should merge at some point? Image is in both our versions though.
Henrik
14-Oct-2008
[1781]
I was editing 0.4.3 from February 2008. Is yours newer?
Geomol
14-Oct-2008
[1782x2]
No, same version:
http://home.tiscali.dk/john.niclasen/postscript/postscript.r
I mean, I haven't done anything else with it since.
Henrik
14-Oct-2008
[1784]
I remember images working fine this spring, but it does not work 
now. I'm wondering what's wrong.
Geomol
14-Oct-2008
[1785]
Ok, what do you wanna do? Anton did a little test, that worked ok. 
I can run the test here too.
Henrik
14-Oct-2008
[1786x5]
I want to do the equivalent of what anton did above, just with to-postscript.
then we can compare
http://rebol.hmkdesign.dk/files/test.ps

That one fails here.
to-postscript layout/tight [text "Page 1" image help.gif]

That's the code for it
Geomol, the code for image that is in your version is:

image: [err:
	'image set name [file! | url! | word!] (

  img: either word! = type? name [get name] [load-image/update name]
		x: img/size/x
		y: img/size/y

I've changed that to:

image: [err:

 'image [set img [file! | url!] (img: load-image/update img) | set 
 img word! (img: get img) | set img image!] (
		x: img/size/x
		y: img/size/y
Geomol
14-Oct-2008
[1791x2]
When I run your test with my version of postscript.r, I get a page 
with a gray box in upper left and the text "Page 1". It's an ok PS 
file here.
Should I see the help.gif image too?
Henrik
14-Oct-2008
[1793x4]
yes, it should be there.
Ghostscript will not run that file here.
ah wait... let me check if your version of to-postscript properly 
supports images
it was wrong. please try again.
Geomol
14-Oct-2008
[1797]
Doesn't work with my version of postscript. Why is the image change 
needed?
Henrik
14-Oct-2008
[1798x2]
because otherwise I can't put images directly into the dialect and 
I will have to store them in a tempory place first and reference 
them with a word => much more code.
the changes I listed above adds image! support directly..
Geomol
14-Oct-2008
[1800x2]
Ah, got it. *thinking*
With the change, I can produce a PS file, but I still can't see the 
image. Will try some stuff...
Henrik
14-Oct-2008
[1802]
There should not be any change in my version of the image decoder.