Hypnotizing Chickens
2009-Sep-11 21:08 UTC
converting gif images to png images on the fly for PDF generation
I have been using the prawn library + prawnto plugin to generate PDF files from a set of models. each model has one or more images associated with it and I include each of these images into the pdf by looping through the images collection associated with the model. (the images have been uploaded with paperclip.) Prawn does not support pdf generation from GIF - only jpg or png. is there a way for me to check if an image is a gif and convert it on the fly into a png image in my prawnto view? I guess converting the image into a png while uploading would also work but as I have a bunch of GIFs already uploaded, and Prawn throws up an "image file is an unrecognised format" when generating the PDF from those models, I would appreciate a solution where the image is converted into a png and included into the pdf. my prawn view: (there are a bunch of cards - each card has a message and 0-n images) @deck.cards.each do |card| pdf.start_new_page pdf.text sanitize(card.message),:align => :center, :size => 30, :style => :bold card.images.each do |pic| pdf.start_new_page picture = "#{RAILS_ROOT}/public#{pic.data.url}".sub!(/\?.+\Z/, '''') pdf.image picture, :position => :center, :vposition => :center end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---