Generate a video from many images using RMagick in RoR - ruby-on-rails

I am trying to generate a video from multiple images using RMagick. The images are saved into ActiveStorage and what I am trying to do is
images = Magick::ImageList.new(*["#{url_for(Post.first.image)}","
{url_for(Post.last.image)}"])
images.write("new_video.avi")
but that way seems not really working so basically all I want is calling images from activestorage and display them like a video. Any ideas?

Rmagick doesn't support video formats. You can generate a gif using the ImageList class with some time between each image. Here you can find a lot of good examples.
Alternatively if you really need an AVI file you can switch to other libraries for example ffmpeg. Example here

Related

Processing file before upload using ActiveStorage

How would I process a file before it's uploaded using activestorage. I need to be able to modify an svg file's content before it actually gets uploaded to S3. Can't seem to find any callbacks.
There is no way to do this natively with ActiveStorage. It's the major drawback with using ActiveStorage.
As far as I know, the only way to modify an upload is to create a variant of the original upload after it is created...which creates a (completely different) variant image based on the image that was originally uploaded.
ActiveStorage is easy to setup but, after using it with a few applications, Carrierwave..etc seem like better options.
In addition, if you want to upload in a background job, ActiveStorage is a pain.

How do you use the pdf-forms gem to form-fill a PDF with images?

I'm trying to put together several different pieces, and I'm not sure if it's even possible.
I know you can use the pdf-forms gem to form-fill a PDF in Ruby on Rails.
I know it's possible to create a form-fillable PDF with adobe acrobat.
I know it's possible to upload images into adobe acrobat form-fillable PDFs -- I've seen several forms that do this.
I'm trying to figure out how to line the pieces up so users can upload images, which are then (programmatically) form-filled into the PDF.

Which plugins/gems should I use to dynamically generate thumbnails on-the-fly in Rails 3?

So, the thing is. I'm building my first rails app which reads images from a directory and it's subdirs. Now, I want to generate dynamic thumbnails of those images. But I don't want to fill up that directory with the thumbnail images. I was thinking of caching these thumbs separately for each user in temporary directory.
Oh, and, I would also need the dimensions of the images for some css magic.
What plugins/gems/... should I use to accomplish this?
You should rmagick coupled with Paperclip. In this way you can specify the dimensions (and many other attributes of the images), and make thumbnails on the fly.
On top of this, I would also add in delayed_job which will background the process of the images so if any of them are provided by the client, they won't have to wait for it to complete client-side.
rMagick : http://github.com/rmagick/rmagick
Paperclip: http://github.com/thoughtbot/paperclip
delayed_job: http://github.com/collectiveidea/delayed_job

which gem to use for uploading photos for making albums

hi i've been googling around and cant really find the most obvius answer for which gem would be best to use.
if i would be using it for lets say creating albums, avatars and thumbnails. that means also allowing multiple pictures upload, ofcourse resizing them and maybe adding them borders.
i've come across RMagick, MiniMagick, PaperClip, Attachment_fu, Attribute_fu, ImageScience
which one do you reccomend and why? probably PaperClip would be best to handle simple stuff here. or maybe MiniMagick also. i'm not sure.
would appreciate any comments on these gems for uploading photos.
I would go with PaperClip. You will need to install RMagick and ImageMagick as well.
PaperClip gives you the ability to attach the images to columns in your model and easily implement them in your views/controllers.
RMagick provides a Ruby API to ImageMagick (which is a popular image manipulation library). You will need to install both ImageMagick and then RMagick. Then you can do things like create thumbnails and resize images programmatically. Almost all of the file attachement libraries will require RMagick/ImageMagick.
(I've also used attachment_fu in the past, that is a good gem as well -- PaperClip seems to be the most popular these days though.)

Rails: attachment_fu plugin, convert PDF uploads to image

Yo,
I've got attachment_fu set up on my server, and it works just fine. My goal, however, is to be able to upload PDFs and have them convert to image (then use all the pre-built attachment_fu options like resize and thumb produce the desired images). What currently happens is that PDFs upload and remain PDFs, whereas images go through all the motions of resizing and whatnot.
How can I get the functionality I want? Is there a simple way to go about doing this using the tools I already have, or should I just manually invoke RMagick to do the initial conversion? If so, how can I do that and then pass off the file to attachment_fu for handling?
Thanks,
--Matchu
For the oldest unanswered rails question: https://stackoverflow.com/a/69804/156561 his answer is probably very similar to get you in the door to use Attachment_fu which I'm sure you've by now migrated off.

Resources