# RMagick PNG issue

**URL:** <https://www.ruby-forum.com/t/rmagick-png-issue/89265>\
**Category:** Rails\
**Created:** [March 19, 2007, 4:51am UTC](https://www.ruby-forum.com/t/rmagick-png-issue/89265 "2007-03-19T04:51:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serdar\_KSSSSlSSSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@Serdar\_KSSSSlSSSSSS](https://www.ruby-forum.com/u/Serdar_KSSSSlSSSSSS)\
**Post date:** [March 19, 2007, 4:51am UTC](https://www.ruby-forum.com/t/rmagick-png-issue/89265/1 "2007-03-19T04:51:51Z")

</div>

Hello all,  
I have a small routine to upload images from a browser and save them  
on the server utilising RMagick (v1.15.3). Things are working well as  
long as the image format is JPG, if I try using a PNG image it barfs  
with a NoMethoError for the resize\_to\_fit! method.

The error is:  
You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.resize\_to\_fit!

Here’s a snippet of the code  
strimg = Base64.encode64(picture.read)  
img = Magick::Image::read\_inline(strimg).first  
img.resize\_to\_fit! 640, 480

Any ideas?

–  
Cheers,  
Serdar Kilic

> **[kilic.net](http://weblog.kilic.net/)**
>
> kilic.net - the weblog of Serdar Kilic

---

<div class="post-metadata">

**Author:** ![Serdar\_KSSSSlSSSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@Serdar\_KSSSSlSSSSSS](https://www.ruby-forum.com/u/Serdar_KSSSSlSSSSSS)\
**Post date:** [March 19, 2007, 1:32pm UTC](https://www.ruby-forum.com/t/rmagick-png-issue/89265/2 "2007-03-19T13:32:25Z")

</div>

Serdar KÄ±lÄ±Ã§ wrote:

> Any ideas?

Are you sure the underlying ImageMagick/GraphicsMagick was built with  
libpng?

–Al Evans
