broken PNG files with GD backend

I attached a '_gd.dll'. This is the C python

    > extension that the module from gdmodule imports.
    > It goes directly in site-packages. I built it
    > statically linked to zlib, libpng, freetype and the gd
    > lib. I don't have the time at the moment to fuss with
    > getting it to use the dlls. ( or to add the jpeg
    > support ) The precompiled windows GD dll in particular
    > seems to not export a few functions that gdmodule
    > wants which is a real pain.

Excellent, the easier the better...

    > 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 to pass the
    > filename rather than a file object, this is the only
    > modification to Matplotlib I had to make.

Could be that I don't have the text bounding boxes exactly right in
gdmodule. In there is a line on or around line 454

if 0:

if you replace that with

if 1:

the text bounding boxes will be displayed. If they are not exactly
right, then the text layout will also be off. I'll take a look when I
get some time, but in the mean time you may want to see for yourself.

Re: gdmodule on windows. What did you do for fonttools? Did you also
build this yourself? If I recall correctly I built it once on windows
without too much difficulty (back when I was trying to get gd working
on windows) but it's been a while and I didn't keep notes. I didn't
see an installer on the sf site.



        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:jdhunter@…8…] Sent:
    > Friday, January 23, 2004 6:58 AM To: Kuzminski, Stefan
    > R Cc: Subject:
    > Re: [Matplotlib-users] broken PNG files with GD
    > backend

"Kuzminski," == Kuzminski, Stefan R <SKuzminski@...79...>

    > writes:

    > Now on to my specific problem. I'm using the GD
    > backend on Windows with Matplotlib 0.41.

    > 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.

    > If I set the dpi to over 60 the png file that gets
    > generated is 'empty', it's only 17 bytes long. As soon
    > as I drop he DPI to below 65 or so, I get the image
    > file correctly. This is with the
    > 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?

    > John Hunter