I've run into an annoying problem with Paperclip. Paperclip is working fine for uploading jpg/gif files but it's choking on .targa files with the error "not recognized by identify”. Just to confirm, it's working 100% with jpg/gif/png files and I have imagemagick installed and working, this error only occurs with .tga files.
The general process for paperclip is:
- User uploads a file
- Tempfile is created containing the contents of that file
- The identify command is run on the Tempfile to get the width/height of the image.
With jpg/png/gif files, iden开发者_如何学Gotify can run on file without needing a valid extension (eg .jpg) to be able to recognise the file type. However, when identifying a .tga file, it requires the ".tga" extension in the file name.
The problem is this:
When Paperclip creates the temp file, it creates with a name similar to: stream.0.1. Because this tempfile lacks the .tga extension, the identify command can not parse the dimensions of the image, thus causing the "not recognized by identify”.
I'm not sure how to go about fixing this, the best idea I can come up with is to use the regular File.new command rather than Tempfile.new to create the temporary file with a random name but the correct file extension. This would require also patching in custom code to remove the Files after processing has been done rather than relying on Ruby's inbuilt ability to delete tempfiles after use.
Does anybody have some ideas on the best method I could go about fixing this?
This was a bug in Paperclip and has been fixed. More details can be found here:
http://groups.google.com/group/paperclip-plugin/browse_thread/thread/7fd7a8d7bab696a7
精彩评论