开发者

Paperclip is failing on certain images but continuing to assign the image to a model

my app integrates with FB. When the user has no image, FB returns:

https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yp/r/yDnr5YfbJCH.gif

While that looks like a normal gif, it breaks paperclip:

[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "x50" -crop "50x50+14+0" +repage '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-1r9c5af-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "300x300>" '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-1cjw8np-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "100x100>" '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-1n3nk3x-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "x25" -crop "25x25+7+0" +repage '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-rhm4uk-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0开发者_StackOverflow社区>

Even with the error, paperclip still saves the image to the model.

Questions:

  1. Why is it breaking?

  2. How can I tell paperclip that if there is a processing error, abort the image, not the entire process as I'm also saving names etc, but at least stop the image from saving a dead file that ends up 404ing.

Thanks


It looks like it is actually a corrupt image. Downloading it and running identify -format %wx%h yDnr5YfbJCH.gif throws the error:

identify: corrupt image `yDnr5YfbJCH.gif' @ error/gif.c/PingGIFImage/958.
200x126

So you can blame Facebook for that one.

Rob on Rails has a good example on how to validate that an upload is a valid image. That should make things work nicely for your end users.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜