Topic: Gruff graphs: Unknown Format PNG exception

Does anyone else have this problem?  If I change the default format to jpg in the base.rb:440 file it works fine, but I think that png would produce a much smaller file due to the simplicity of the graphs.  There is a good chance that I am missing a library, but since everything works fine with the jpg format I am not sure what library it would be.

Here is the code change

    # Return the graph as a rendered binary blob.
    def to_blob(fileformat='jpg')  #used to be PNG
      draw()
      return @base_image.to_blob do
         self.format = fileformat
      end
    end

Thanks for the help.

Re: Gruff graphs: Unknown Format PNG exception

Hey iso,

I had the exact same problem last week. Turns our our server was missing a library needed for PNG rendering by ImageMagick. Here's the email from the great tech support over at Rails Playground:

"libpng-devel was not installed which causes png support to not work correctly with imagemagick. I've installed libpng-devel and recompiled imagemagick, let me know if that doesn't clear up this error."

We have a linux Virtual Private Server with the Playground, so hopefully that will help your problem too.

Also, you can call to_blob('JPG') in your controller, so you don't have to modify the actual gruff source code, which can bite you in the ass if you deploy on multiple machines!

The

def to_blob(fileformat='png')

call sets fileformat equal to PNG if there is no argument included when to_blob is called, but you can overwrite it by doing what I suggested. Hope that helps!

Re: Gruff graphs: Unknown Format PNG exception

Hey Harmon,

Thanks for digging this post up and letting me know.