From: Kuzminski, S. R <SKu...@fa...> - 2004-01-29 12:20:11
|
Some notes on compiling GD backend for windows. 1) _gdmodule.c needs to be modified in 2 places to compile on windows=20 a) line 1888 PyObject_HEAD_INIT() needs to passed a NULL. This is in the Python docs. =09 .... static PyTypeObject Imagetype =3D { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ .... b) the init_gd function ( line 1957 ) needs to have '_declspec(dllexport)' added to the declaration.=20 ..... /* Initialization function for the module (*must* be called init_gd) */ void _declspec(dllexport) init_gd(void) {=20 .... 2) This one took me a long time to figure out. For some reason opening a windows file in Python with 'wb' permission will cause the png files to be corrupted above a certain image size. If you pass the filename to gdmodule, then the gdmodule opens the file and it works. I imagine that the python call "open( 'filename', 'wb' )" just calls fopen, furthermore I thought that binary mode only applied to reading files. At any rate, I have no idea why this doesn't work in this case but it doesn't. To get it to work, I had to change line 261 in backends_gd.py to pass the filename rather than a file object, this is the only modification to Matplotlib I had to make. im.writePng( filename ) #2 above is the answer to the problem in my original post. However I have another question. When I set the ylabel rotation to be horizontal, the beginning of the text is truncated ( the width of the border does not compensate ). I'm happy to set it wider but am wondering how ( what controls the width of the area where the labels gets written ). I also noticed that title of the graph ( with the horizontal alignment set to bottom ) is too close to the top of the graph itself, is there a way to pad that? thanks, Stefan -----Original Message----- From: John Hunter [mailto:jdh...@ni...]=20 Sent: Friday, January 23, 2004 6:58 AM To: Kuzminski, Stefan R Cc: mat...@li... Subject: Re: [Matplotlib-users] broken PNG files with GD backend >>>>> "Kuzminski," =3D=3D Kuzminski, Stefan R <SKu...@fa...> writes: Kuzminski> Now on to my specific problem. I'm using the GD Kuzminski> backend on Windows with Matplotlib 0.41. =20 First things first -- I haven't succeeded in getting the gd backend compiled on windows. If you have some expertise here and are willing to share, or better yet build a gdmodule and gd installer that I can put on the website, I would be very much obliged! I contacted the gdmodule maintainer some time ago over this issue and he had never built it on windows either. In my googling, I discovered the perl gd module for windows and following their lead, succeeded in building gd lib, but ran into some troubles (can't remember what) building gdmodule. Kuzminski> If I set the dpi to over 60 the png file that gets Kuzminski> generated is 'empty', it's only 17 bytes long. As soon Kuzminski> as I drop he DPI to below 65 or so, I get the image Kuzminski> file correctly. This is with the simple_plot.py Kuzminski> example. Now on to your problem. Is there a typo here? You say over 60 is empty and under 65 is ok ?? Can you send me a script which replicates the problem, with the two calls to savefig, one which has the problem and which does not. Then I can begin to diagnose the problem; see if it occurs under linux, see if it's a gd problem, see if it's a problem on my end, etc.... Are you using matplotlib + GD for a web app server? =20 John Hunter=20 =20 |