From: Markus M. <me...@me...> - 2004-05-04 10:25:53
|
Hi, this is maybe slightly offtopic, if so, sorry. I'd like to output both vector graphics and raster images (bitmaps) using the PyX library and output a .PS file I can send to the printer (not an .EPS file). My questions are: 1. Am I correct that I can output poth .EPS and standard printer-friendly .PS postscript files with PyX? 2. Is there currently any support (planned) for raster images in PyX? 3. If not, what would be the most logical way to add it and/or is it possible to send postscript commands in "raw" mode through PyX to get this functionality? If you think PyX is not the right library for this, do you know of any other libraries (Python or C) that provide this functionality? Any pointers greatly appreciated. Markus |
From: Joerg L. <jo...@us...> - 2004-05-04 14:10:35
|
Hi Markus, On 04.05.04, Markus Meyer wrote: > this is maybe slightly offtopic, if so, sorry. I'd like to output both > vector graphics and raster images (bitmaps) using the PyX library and > output a .PS file I can send to the printer (not an .EPS file). My > questions are: > > 1. Am I correct that I can output poth .EPS and standard > printer-friendly .PS postscript files with PyX? Yes. > 2. Is there currently any support (planned) for raster images in PyX? No, there is no support for raster images and we also do not intend to implement this feature. Just use Ghostscript to generate bitmap files from the PostScript produced by PyX. > 3. If not, what would be the most logical way to add it and/or is it > possible to send postscript commands in "raw" mode through PyX to get > this functionality? What do you mean with 'send postscript commands in "raw" mode through PyX"? Do you think of passing the PostScript output of PyX directly to Ghostscript? > If you think PyX is not the right library for this, do you know of any > other libraries (Python or C) that provide this functionality? There are many libraries for generating bitmaps directly, but I have never used one of the - so I cannot recommend a particular one. Joerg |
From: Markus M. <me...@me...> - 2004-05-04 14:38:16
|
Joerg, thanks for the quick reply. My answers below. Am Die, den 04.05.2004 schrieb Joerg Lehmann um 16:09: > > 1. Am I correct that I can output poth .EPS and standard > > printer-friendly .PS postscript files with PyX? > > Yes. Thanks, that sounds good. > > 2. Is there currently any support (planned) for raster images in PyX? > > No, there is no support for raster images and we also do not intend to > implement this feature. Just use Ghostscript to generate bitmap files > from the PostScript produced by PyX. No, sorry, seems like I misformulated my question. I do _not_ want to create bitmaps from the postscript code which is created by PyX (that would be possible with e.g. Ghostscript as you described.) In contrast I'd like to know if I can insert raster images into the output. E.g, I'd like to draw a diagram with PyX and next to the diagram print a .PNG image (say, a photograph). This could be implemented by a drawing primitive (like Window's "BitBlt()" or "DrawImage()"), for example. > What do you mean with 'send postscript commands in "raw" mode through > PyX"? Do you think of passing the PostScript output of PyX directly > to Ghostscript? My intention was that, if PyX is not supporting to insert raster images into the output, I could still insert the raw postscript code for printing the raster image into the output PyX produces. Of course, a generic solution would be much preferred. Markus |
From: Joerg L. <jo...@us...> - 2004-05-04 15:11:41
|
Hi Markus, On 04.05.04, Markus Meyer wrote: > > > 2. Is there currently any support (planned) for raster images in PyX? > > > > No, there is no support for raster images and we also do not intend to > > implement this feature. Just use Ghostscript to generate bitmap files > > from the PostScript produced by PyX. > > No, sorry, seems like I misformulated my question. I do _not_ want to > create bitmaps from the postscript code which is created by PyX (that > would be possible with e.g. Ghostscript as you described.) > > In contrast I'd like to know if I can insert raster images into the > output. E.g, I'd like to draw a diagram with PyX and next to the diagram > print a .PNG image (say, a photograph). This could be implemented by a > drawing primitive (like Window's "BitBlt()" or "DrawImage()"), for > example. Ah, I see. This is not yet possible but certainly something that would be nice to have. > My intention was that, if PyX is not supporting to insert raster images > into the output, I could still insert the raw postscript code for > printing the raster image into the output PyX produces. Of course, a > generic solution would be much preferred. Ok, this is not too difficult to implement. Bascically you have to derive from the PSCmd class and offer two methods: def outputPS(self, file): """write PS code to file""" def bbox(self): """return bbox of PSCmd""" You can then insert instances of your new class into a canvas and everything should work flawlessly. Joerg |
From: Andre W. <wo...@us...> - 2004-05-04 14:59:29
|
Hi, On 04.05.04, Markus Meyer wrote: > this is maybe slightly offtopic, if so, sorry. I'd like to output both > vector graphics and raster images (bitmaps) using the PyX library and > output a .PS file I can send to the printer (not an .EPS file). My > questions are: > > 1. Am I correct that I can output poth .EPS and standard > printer-friendly .PS postscript files with PyX? PyX currently creates EPS files, which are valid (single page) PostScript at the same time. Thus you can just print those files on a PostScript printer without further efforts. Using the paperformat option of the writeEPSfile method, you can even center your output on a specified paper format while keeping the possibility to insert the EPS file in another document without additional borders etc. > 2. Is there currently any support (planned) for raster images in PyX? There are two questions arising here: (2a) inclusion of raster images and (2b) creation/modification of raster images. (2a) is an interesting subject, but as far as I can tell, none of the current developers plans to spend time on that in the near future. However it would be very nice to have a component, say a bitmap-module, which allows to insert raster images into a canvas. This module should be aware and take advantage of certain compression features available in PostScript. For example, via jpeg2ps it is possible to build quite efficient PostScript code out of an existing jpeg image. While currently you can use jpeg2ps to create an EPS file and include that into PyX (I did that myself already), it would be nice to have such a functionality available within PyX. (2b) is clearly out of scope for PyX. However, it could be possible to use the PIL for that. Once we have (2a) it should be possible to make use of PIL for creating/modifying some raster images and inserting the result into PyX within a single python script ... > 3. If not, what would be the most logical way to add it and/or is it > possible to send postscript commands in "raw" mode through PyX to get > this functionality? The first part of the question is already answered above. About the second part: It is possible to create a PSCmd, which you can then insert into a canvas, thus writing arbitrary PostScript yourself. Its up to you ... ;-) > If you think PyX is not the right library for this, do you know of any > other libraries (Python or C) that provide this functionality? IMHO it just depends on your needs. If you mainly want to take advantage of the programmable vector graphics system PyX provides and you just want to insert certain bitmaps, a conversion into of those bitmap files into PostScript previous to its inclusion into PyX might work for you. André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ |
From: Francisco V. <fra...@hi...> - 2004-05-04 15:18:55
|
El mar, 04 de may de 2004, a las 12:25:15 +0200, Markus Meyer dijo: > Hi, > > this is maybe slightly offtopic, if so, sorry. I'd like to output both > vector graphics and raster images (bitmaps) using the PyX library and > output a .PS file I can send to the printer (not an .EPS file). My > questions are: > > 1. Am I correct that I can output poth .EPS and standard > printer-friendly .PS postscript files with PyX? I think you always can do 'lpr filename.eps' in UNIX with magicfilter and it prints well. > 2. Is there currently any support (planned) for raster images in PyX? > 3. If not, what would be the most logical way to add it and/or is it > possible to send postscript commands in "raw" mode through PyX to get > this functionality? If you have GhostScript, do: gs -sDEVICE=png256 -sOutputFile=box.png box.eps to convert box.eps to a png in 256 colors. The variety of DEVICES is enormous. Magicfilter converts internally to a pnm format file using gs before printing to my laserjet, I think. I sometimes obtain the following warning: Some of the BoundingBox for the EPS file will be clipped. Use -dEPSCrop or -dEPSFitPage to avoid clipping. -- Francisco Vila Doncel. Badajoz (Spain) http://www.paconet.org |