[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

500 errors with GD2 image generation

Cheshire Cat

6/1/2006 7:38:00 PM

I've created an application with Rails that uses Ruby/GD2
(http://gd2.ruby...) to create raster images. I've had trouble
with image corruption from the beginning, and this is an issue I never
had with GD in PHP. I don't know if it's due to a) a bad set of Ruby
bindings and I should use something other than Ruby/GD2, b) something
Rails-specific that's different from PHP and causes image corruption,
or c) something else. It seems that JPEG's are by far the most
forgiving format, because even when they're corrupt, the image still
loads in the browser, whereas with corrupt PNG's and GIF's, I just get
either a) a 500 error or b) a note about the image having errors.
Maybe this is more with how Firefox handles its images.

However, I shouldn't even have to worry about how Firefox or other
browsers handle corrupt images because I shouldn't be getting corrupt
images in the first place. I'm doing very straight-forward stuff
involving generating a table of text and shapes, black and other
colors.

Some of the things that have seemed to reduce corruption:
- making sure nothing overlaps: text gets truncated to fit in a
certain column width, because when it overlaps into the other column of
text, I get corruption; the same goes for if shapes overlap other
things in the image
- reducing the image quality: I don't know what Ruby/GD2's default
JPEG quality is, but setting it to 70 seems to remove corruption

By corruption, I mean artifacts. Example: the image will be fine up
until a certain row, and then the background will suddenly switch to
some seemingly arbitrary color, there will be a little blotch of gray,
and the rest of the image has that strange color kind of overlaying the
rest of the data.

I'm using Rails 1.1.2, Ruby 1.8.4, FastCGI with Apache, and GD
2.0.33-2.

Does anyone have any ideas about why I might be getting corrupt images
or how to fix them?