500 errors with GD2 image generation

C

Cheshire Cat

I've created an application with Rails that uses Ruby/GD2
(http://gd2.rubyforge.org/) 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top