The problem occurs when i try to manipulate an image uploaded from sinatra.
File.open(params[:file][:tempfile]) do |p|
thumb = Magick::Image.read(p)
thumb.crop_resized!(75, 75, Magick::NorthGravity)
end
The uploaded file is a jpeg, form data when uploading image includes
{:filename=>"299732_176749115737355_100002068035867_380115_618512842_n.jpg", :type=>"image/jpeg", :name=>"file", :tempfile=>#<File:/var/folders/hf/d6vx6vg56nbd5n44jjrp84k80000gn/T/RackMultipart20120228-55947-1fd2l6c>, :head=>"Content-Disposition: form-data; name=\"file\"; filename=\"299732_176749115737355_100002068035867_380115_618512842_n.jpg\"\r\nContent-Type: image/jpeg\r\n"}
And also ImageMagick has the necessary delegates
convert -list configure
returns
DELEGATES bzlib freetype jpeg jng jp2 lcms png tiff x11 xml zlib
So, i should be able to upload and transform a jpeg, but it whines about delegates. Also i am working on Mac OSX 10.7, maybe another weird problem with mac
I found solution for me:
tmpfile = params[:file][:tempfile]
image = Magick::ImageList.new
bin = File.open(tmpfile, 'r'){ |file| file.read }
img = image.from_blob(bin)
I suppose problem occurs because rmagick try to define image type by file extension. But uploaded file without extension. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With