# Bigger image rendering difficulty using RMagick

**URL:** <https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957>\
**Category:** Rails\
**Created:** [August 4, 2008, 6:28pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957 "2008-08-04T18:28:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 6:28pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/1 "2008-08-04T18:28:00Z")

</div>

I am using RMagick for uploading Pictures of Bigger JPG formats.  
I am able to render the images properly at my page if the image pixels  
are below 900x900 pixels, but if the images are bigger lets say when I  
tried to see the images of 3000x3000 pixels JPG pictures after  
uploading, only half of the image is coming up. Only Half of the image  
is coming up for the original and medium\_thumbnail view, but for the  
small\_thumbnail is coming up fine.

But I need the bigger jpg with 3000x3000 pixels to be allowed as a  
mandatory.

Please help and suggest me for my requirements. Thanks in advance.  
NOTE: I am storing the pictures in 3 columns in MySQl as blob files.

## View:

\<% form\_tag({:action =\> ‘upload’}, :enctype =\> ‘multipart/form-data’) %\>  
\<%= file\_field ‘picture’, ‘original’ %\>

## Controller:

@picture = Photo.new(params[:picture])  
@picture[‘original’] = params[:picture][:original].read  
img =  
Magick::Image.read\_inline(Base64.encode64(@picture[‘original’])).first  
img.change\_geometry!(‘580x380’) { |c, r, i| i.resize!(c, r) }  
@picture[‘medium\_thumbnail’] = img.to\_blob

img =  
Magick::Image.read\_inline(Base64.encode64(@picture[‘original’])).first  
img.change\_geometry!(‘80x80’) { |c, r, i| i.resize!(c, r) }  
@picture[‘small\_thumbnail’] = img.to\_blob  
@photo.save

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 6:30pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/2 "2008-08-04T18:30:42Z")

</div>

updated one:  
I am using RMagick for uploading Pictures of Bigger JPG formats.  
I am able to render the images properly at my page if the image pixels  
are below 900x900 pixels, but if the images are bigger lets say when I  
tried to see the images of 3000x3000 pixels JPG pictures after  
uploading, only half of the image is coming up. Only Half of the image  
is coming up for the original and medium\_thumbnail view, but for the  
small\_thumbnail is coming up fine.

But I need the bigger jpg with 3000x3000 pixels to be allowed as a  
mandatory.

Please help and suggest me for my requirements. Thanks in advance.  
NOTE: I am storing the pictures in 3 columns in MySQl as blob files.

## View:

\<% form\_tag({:action =\> ‘upload’}, :enctype =\> ‘multipart/form-data’)  
%\>  
\<%= file\_field ‘picture’, ‘original’ %\>

## Controller:

@picture = Picture.new(params[:picture])  
@picture[‘original’] = params[:picture][:original].read  
img =  
Magick::Image.read\_inline(Base64.encode64(@picture[‘original’])).first  
img.change\_geometry!(‘580x380’) { |c, r, i| i.resize!(c, r) }  
@picture[‘medium\_thumbnail’] = img.to\_blob

img =  
Magick::Image.read\_inline(Base64.encode64(@picture[‘original’])).first  
img.change\_geometry!(‘80x80’) { |c, r, i| i.resize!(c, r) }  
@picture[‘small\_thumbnail’] = img.to\_blob  
@picture.save

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 7:15pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/3 "2008-08-04T19:15:21Z")

</div>

On 4 Aug 2008, at 17:30, Nishi A. wrote:

> But I need the bigger jpg with 3000x3000 pixels to be allowed as a  
> mandatory.
> 
> Please help and suggest me for my requirements. Thanks in advance.  
> NOTE: I am storing the pictures in 3 columns in MySQl as blob files.

You’re probably hitting a limit either on the amount of data you’re  
trying to insert into the column (blob columns have a size limit  
specified when you create the column) or in the maximum packet size  
mysql is using (which is effectively an upper bound on the size of a  
query and hence the amount of data you can insert in one go)

Fred

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 8:02pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/4 "2008-08-04T20:02:14Z")

</div>

might i suggest storing files on the filesystem? [novel, i know.] if  
it’s a matter of privacy you can use send\_file to serve files from  
folders other than public. there’s absolutely nothing gained [as far  
as i can see] from storing images in the database when the file system  
is designed for managing files so well. it seems like storing data in  
flat files on the filesystem or something.

RSL

On Mon, Aug 4, 2008 at 1:14 PM, Frederick C.

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 8:31pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/5 "2008-08-04T20:31:52Z")

</div>

Its going to be a major change if its going to be a filesystem. I need  
to do some research on that also as I am new to filesystem manipulation  
for pictures, if you point me some info on that will be appreciated. But  
meantime I need to figure out if any changes in the blob size could save  
thing, it would be great. Only 3000pixels i need and size may lets say  
3MB. But still wondering in my previous code if you see, why there is  
problem in rendering medium\_thumbnail as it is already resized to  
smaller one and stored.

So still wondering is it only Blob size is the culprit or something to  
do with RMagick.  
For my goodness I am trying to change to LongBlob and check if its going  
to do anything with the Blob size.

What do u say?

Cheers,  
Nish

RSL \_\_\_ wrote:

> might i suggest storing files on the filesystem? [novel, i know.] if  
> it’s a matter of privacy you can use send\_file to serve files from  
> folders other than public. there’s absolutely nothing gained [as far  
> as i can see] from storing images in the database when the file system  
> is designed for managing files so well. it seems like storing data in  
> flat files on the filesystem or something.
> 
> RSL
> 
> On Mon, Aug 4, 2008 at 1:14 PM, Frederick C.

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 11:58pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/6 "2008-08-04T23:58:34Z")

</div>

um… i don’t have references for storing files on the file system.  
sorry. it isn’t really something people write articles and blog posts  
on. it’s just the standard way of doing things. [they call it the  
filesystem for a reason. ;)] feel free to keep on with the leet  
storing files in database. i was just sharing with you the information  
that you don’t really gain anything from doing so and lose a lot of  
what the filesystem is good at.

RSL

On Mon, Aug 4, 2008 at 3:31 PM, Nishi A.

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 5, 2008, 12:06am UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/7 "2008-08-05T00:06:45Z")

</div>

RSL \_\_\_ wrote:

> um… i don’t have references for storing files on the file system.  
> sorry. it isn’t really something people write articles and blog posts  
> on. it’s just the standard way of doing things. [they call it the  
> filesystem for a reason. ;)] feel free to keep on with the leet  
> storing files in database. i was just sharing with you the information  
> that you don’t really gain anything from doing so and lose a lot of  
> what the filesystem is good at.
> 
> RSL
> 
> On Mon, Aug 4, 2008 at 3:31 PM, Nishi A.

Thanks for the info and help RSL.  
Cheers,  
Nishi

---

<div class="post-metadata">

**Author:** ![nishi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@nishi](https://www.ruby-forum.com/u/nishi)\
**Post date:** [August 4, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/bigger-image-rendering-difficulty-using-rmagick/144957/8 "2008-08-04T21:31:00Z")

</div>

After changing to LongBlob from Blob, I tested for couple of 2400 pixels  
sample jpeg files, it looks good so far. Thanks Fred for a quick hint.  
And RSL, if you could give me some info or some links regarding storing  
in FileSystem and managing my requirements, that will be helpfull.  
Thanks again Fred and RSL for your valuable info. Cheers.
