Is it possible to do motivational poster in rails with paperclip gem alone or will I need some kind of image processor like RMAGICK?
Paperclip defers to ImageMagick to process images, so you’ll need it anyway.
Related
I understand there are several gems for image optimizations. However, I haven't come across any gem that will optimize or compress images files such jpeg, as well pdfs and doc files. Is there any gem which will optimize and compress any such files?
Optimization is a broad concept. Compressing images, for example, is optimization in itself. These are inheritently not part of a gem or language library but proper dedicated utilities like ImageMagick.
Gems like Carrierwave lets you upload an image and resize it on the go. Then there is ImageMagick's ruby wrapper, RMagick.
You can look for similar functions for documents/pdf.
I have a Shipcloud.io implementation in my Rails app. A successful API call generates a shipping label in PDF format. I then need to convert the given PDF to another size (DIN A5 format, specifically). How can this be done in Rails? I checked out the wicked_pdf gem but it seems that only generates html to pdf.
Use imagemagick,
then use ruby system call method.
something like,
system("convert original.pdf -resize "{width}x{height}" resized.pdf")
The rmagick gem is one way to go. It uses the imagemagick binary in the background and therefore you have to install it before you can use the ruby gem. I use it everyday for work.
There are also other variants as well. For example the mini_magick gem boosts better memory management and also supports ImageMagick or GraphicsMagick.
https://rmagick.github.io/
https://github.com/minimagick/minimagick
what's the size of the shipping label you're currently getting? For a few carriers you can change the size from within your shipcloud backoffice. The shipping labels are all in standard sizes so be aware that when resizing them you could end up with a label that won't be accepted by the carrier.
How can we scan the images uploaded by Carrierwave for malware? I use it to only upload images. Is it necessary? If so, is there any gems I can use?
I don't think there's a gem for that, but you can scan files for malware using clamscan
It will look like this
if system("clamscan #{path_to_temp_file}")
# save file
else
File.delete(path_to_temp_file)
I'm updating this for future readers but there's now Carrierwave::AttachmentScanner to allow you to scan CarrierWave uploads for viruses and malware (note: this does rely on a third party though Vasile's answer doesn't need any third parties just clamav).
There is a gem for ClamAV. Drifting Ruby Screencast.
Another gem is ratonvirus.
carrierwave with image_magick (and rmagick for that matter) provides methods such as resize_to_fit, etc.
Is there a method I can call to compress my images by, say, 50%?
All you need to know is in the WIKI:
https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Specify-the-image-quality
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.)