Monday, January 24, 2011

[Rails] Magick::Image , no size & Amazon S3

Hi,

Any ideas why I get "undefined method `size' for 100x100 DirectClass
8-bit:Magick::Image" while doing the next?

image = Magick::Image.new(100, 100) { self.size = "100x100"}
logger.info image.size

Thanks.

-------------

This is what I'm trying to do:

I'm using the qr_image.rb to create QR codes for my app.
qr_image.rb is explained here: http://bit.ly/hCFrs1

I'm now trying to store the generated images into Amazon S3.
The upload process complains that the image has no size method. I've
been trying different ways to feed the image size during the creation
with no success.

This is how I use it:

@qr = RQRCode::QRCode.new("Some text", :size => 6)
@img = QRImage.new(@qr).sample(10)

logger.info @img.size return a noMethod error and breaks the next part

AWS::S3::S3Object.store( "#{id}.png", @img, aBucketinS3 )


This is how I use it normally to store to file system and goes fine.

@qr = RQRCode::QRCode.new("Some text" :size => 6)
FileUtils.mkdir_p "public/images/tags/#{ident}"
@img = QRImage.new(@qr).sample(1)
path = "public/images/tags/#{@tag.identifier}/#{ident}_thumb.png"
@img.write(path)

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate