which gem to use for uploading photos for making albums - ruby-on-rails

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.)

Related

Generate a video from many images using RMagick in RoR

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

uploading a file with rail - what is the best approach

I have a requirement of uploading a file to my disk through my webpage. Seems like I have two options
My requirement is specific that I will upload ONLY text files.
Using default rails methods to upload a file.
Ex: http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm
Using a plugin like 'PaperClip'
Following are my concerns:
I want to keep the file upload as simple as possible
Keep as away as dependencies like Imagemagic etc
I'm using rails 2.8.3
concurrent file uploads can be happen by multiple users
please can someone tell me what are the pros and cons of having
writing a simple file upload (option 1)
using a plugin/gem to upload a files
Writing your own file uploader is an option, but using a pre-built gem provides you with all of the code you need, straight after install.
Gems will usually have all of the functionality packaged into them that handles all of the cross-platform issues and security headaches your likely to run into by writing something from scratch. A well maintained gem will also have a good community behind it, keeping things up to date.
The popular Gems out there are really easy to use, and unless you are resizing images etc, you shouldn't need ImageMagick installed. Have a look at these:
http://railscasts.com/episodes/134-paperclip
https://github.com/technoweenie/attachment_fu/wiki
Paperclip is far easier to build a simple upload form with, but I'm not sure if it works on Rails 2. Attachment_fu is an old favorite from the Rails 2 days and will definitely be able to handle your problem, it just requires a little more configuration.

File uploading rails 3

I have a rails 3 app that has a comment system that allows a user to make comments. What I now wish to do is extend this further by enabling the user to attach/upload files to the comment system. Fairly easy question I am about to ask. What is the best tool/plugin or gem to use so that I can achieve this? I've done some thorough research and found that alot of these plugins such as carrierwave, paperclip and a few others are used to upload photos and I am not trying to do this.
Requirements
User should be able to upload/attach files
Can upload word, powerpoint or execel docuements
Both carrierwave and paperclip can be used to upload any type of files - they have extra features if you want to upload images, but they are not restricted to handling just image files.
In the end it's a matter of preference. I found both paperclip and carrierwave to be very good at what they do.
Paperclip
CarrierWave
As for me CarrierWave more modern and nice solution. Have a try.
You can use even dragonfly - https://github.com/markevans/dragonfly/

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.

Image upload in rails

How do I upload images and zip files in RoR? I am a newbie. So please help.
Give me both the view and the controller code example.
Thanks in advance.
Nav,
Try the paperclip plugin, you can read about it here http://www.thoughtbot.com/projects/paperclip
We prefer CarrierWave for image uploads in Rails. Very easy to integrate and very modular.
The following post describes a solution for image uploading using CarrierWave while image transformations are done seamlessly in the cloud. Uploaded images are stored in the cloud and delivered through a CDN.
No need to install RMagick, MiniMagick and ImageMagick.
http://cloudinary.com/blog/ruby_on_rails_image_uploads_with_carrierwave_and_cloudinary
suggest checking out the Railscast for paperclip.
ImageMagick is also pretty cool
I would recommend paperclip, and the patch that allows you to store the content in the database instead of the file system
http://patshaughnessy.net/paperclip-database-storage
the link has the view and controller examples that you are looking for
I prefer carrierwave is better to upload images easily.
Here's github page , and railscasts page for quick start.
One option is attachment_fu. It allows you to save your uploaded file to the filesystem, database, or Amazon S3. It also allows you to select which image processor is used, such as RMagick or Minimagick.
The link provides better code than I could here.

Resources