views:

125

answers:

1

I'm trying to upload an image from Flex to Rails. It uploads fine if I just want to upload the original but when I tried to add Thumbnail I got the following error:

[paperclip] identify '-format' '%wx%h' '/var/folders/RH/RHekFGKME9uDJbX4d4DG3E+++TI/-Tmp-/stream,23830,0.jpeg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/RH/RHekFGKME9uDJbX4d4DG3E+++TI/-Tmp-/stream,23830,0.jpeg is not recognized by the 'identify' command.>
[paperclip] identify '-format' '%wx%h' '/var/folders/RH/RHekFGKME9uDJbX4d4DG3E+++TI/-Tmp-/stream,23830,0.jpeg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/RH/RHekFGKME9uDJbX4d4DG3E+++TI/-Tmp-/stream,23830,0.jpeg is not recognized by the 'identify' command.>

and I noticed for some reason in the DB that when I upload a file from Flex to Rails it puts the photo_content_type is application/octet-stream shouldn't be jpeg or something? I thought that might be the problem.

Do you know how to resolve this?

A: 

For the photo_content_type -- flash is known to not send the correct mime-type, so I recommend you use mimetype-fu to get the real mime-type

If that doesn't solve your problem comment here and include if this is your development environment and if you're on a mac. It sounds like your environment can't find the rmagick binary. Follow these instructions

/config/intializers/paperclip.rb

Paperclip.options[:image_magick_path] = ‘/opt/local/bin/identify’

Alertnative, this has worked for a colleague:

unless RAILS_ENV == "production"
  Paperclip.options[:command_path] = "/opt/local/bin"
end

On my mac, it's in /opt/local/bin/identify ... if you're on a mac, type in "which identify" to find your binary.

Jesse Wolgamott
Thanks Jesse. I tried your suggestions. mimetype-fu didn't seem to resolve the issue it gave me unknown/unknown. Also adding the other commands didn't seem to resolve the issue :( any ideas?
Tam
Can you look at the file that's saved and confirm that it is a valid jpg/png/whatever image file?
Jesse Wolgamott
Yeah I did. I tried multiple PNG/JPEG files. It might be an issue with identify command: identify somefile.jpgand I get the following:identifydyld: Library not loaded: /opt/local/lib/libfontconfig.1.dylib Referenced from: /usr/local/bin/identify Reason: no suitable image found. Did find: /opt/local/lib/libfontconfig.1.dylib: mach-o, but wrong architecture.... I posted a question in Super User regarding this.
Tam
I think RMagick is not properly installed. Are you using a mac? It's difficult.
Jesse Wolgamott
Yes I'm using Mac. Can you suggest how to to check if it's properly installed? or maybe a link where I can re-install it to make sure it's installed properly.
Tam
Run this code to see: http://codesnippets.joyent.com/posts/show/1589 .. it created a graph looking .gif file for me
Jesse Wolgamott
Thanks @Jesse your suggestions helped. I actually deleted all Mac Ports and reinstalled them then used your code above for Rails and it resolved the problem
Tam