thoughtbot / paperclip

Easy file attachment management for ActiveRecord
https://thoughtbot.com
Other
9.01k stars 2.43k forks source link

PDF post_process producing black jpgs #310

Closed uberllama closed 12 years ago

uberllama commented 14 years ago

Hi folks. Thought I'd throw this one out there to see if anyone had any ideas. In a past project on Leopard, I used paperclip to create jpg previews from pdfs with a bit of code like this: has_attached_file :upload, :styles => {:thumb => ['400>', :jpg]}

I've been working on a new project using paperclip on snow leopard and al of my pdf resizing is producing black jpgs. I'm using image magick via the maddox magick installer http://github.com/maddox/magick-installer and ghost script runs fine from the command line. I don't see any errors in my dev log.

Any ideas?

sorentwo commented 14 years ago

Do the PDFs you are processing happen to be CYMK? I have found drastically unpredictable results with ghostscript's PDF processing, especially when generated for print from something like InDesign.

uberllama commented 14 years ago

No, in fact most of the PDFs I've been testing have been simple text documents, web sites saved as PDF, and so on.

sikachu commented 13 years ago

That sounds like ImageMagick/GhostScript issue. Did you managed to fix it?

uberllama commented 13 years ago

Nope, never did get pdf previews working.

jyurek commented 12 years ago

If this is still an problem, can you try converting the PDF to a jpeg manually on the command line and let us know the result? The command should be as simple as convert file.pdf file.jpg and if that works, we can add in more options that Paperclip uses.

uberllama commented 12 years ago

Just tried and get a black jpg as before.

sorentwo commented 12 years ago

I explored this pretty thoroughly back when this issue was opened. It isn't a paperclip issue, it has to do with the colorspace of the PDF itself and GhostScript. If you're willing to pay for it you can use pdf2image, which has much more predictable (and faster) results.

jyurek commented 12 years ago

Thanks for the reports, @uberllama and @sorentwo. This sounds like it's definitely an ImageMagick (or at least ghostscript) issue. While it'd be awesome to know how to get around it, I'm not actually that good with IM. Perhaps someone on their forums/mailing list would be a better person to answer.