I want do same working like php timthumb do in ror I tried gems but not found result as I want.
Images are taking much time to load.
for example code in php :
Can check what I required on :
http://www.darrenhoyt.com/demo/timthumb/
I want same way in ror?
You can try minimagick gem to compress image size and quality.
For example:
image = MiniMagick::Image.open(YOUR_IMAGE)
image.resize "130x100" ## The thumbnail size
image.write(YOUR_THUMB)
When you upload an imagine you want to have different sized versions that have been processed from the original.
Carrier wave to upload the image and resize it
https://github.com/carrierwaveuploader/carrierwave
You can resize as documented here: Carrier Wave - Versions
To be more precise here are associated tutorials for what you want using carrierwave and various libs for the conversions: Image Dimensions
You can even change the image type to keep a standard and do more image processing with libraries. Here is how: Image Processing
Related
I have user gallery at remote areas where internet speed is limited. And, they can upload multiple documents when asked.
In that case, when I am not suppressing the document image.. it takes time to upload the document and on the other hand, when I do, document loose readability.
So, here, I am finding the way to upload multiple documents with full resolution but without losing quality.
And, document image can be in any format jpg, jpeg, png etc.
Thanks in advance for your help.
I check this Image upload without loss of quality but didn't help it.
The link is .NET, you need Swift, right?
You have a image named "originalImage". The code below compress this image and create a new, smaller one with same resolution. The value (0.8) is compression level.
Upload "compressedImage" to server.
let compressedImage = UIImageJPEGRepresentation(originalImage, 0.8)
I used to get an image from the frontend and store it in the backend.
How can I compress that image before storing it to the database?
Is there any gem for compressing an image?
or any other way to do that?
Take a look at carrierwave gem. It is a wrapper for ImageMagick, that lets you process uploaded files before storing them (e.g. resize, convert, optimize etc).
What is the role of Augmented Images Database?
I am using arcoreimg tool to generate the img database, but why do need to generate it. I know it is a very basic question please provide your guidance
I am new to AR following Google AR SDK, Please help.
The role of the AugmentedImageDatabase is to store a compressed representation of the images you'd like to track. This is used by ARCore to detect images in the real world.
Generating a database at compile time with the arcoreimg tool has several advantages:
Your app no longer needs to bundle the original PNG or JPEG files. Your app would instead include a smaller database file, resulting in a smaller APK size.
Your app no longer needs to decode the original PNG or JPEG files to extract the image's feature points at runtime. This is an operation which takes roughly ~30ms for each image.
In a Rails 4 app, we have some big images on our homepage (the dimensions are like 2400px on width) and naturally, their loading is quite slow.
What are the options to speed up loading them? One way is to decrease their quality => their size => faster loading.
But is there a Rails way how to pre-cache/compress them?
Thank you.
There is no "Rails way" to do this. This is a problem no matter what framework/language you're using and is best solved with a content delivery network (aka CDN)
One good practice is to run all images through ImageOptim before the final commit into your codebase. This tool does lossless compression, meaning the pixels don't change and it still reduced file size.
That's not a "Rails" solution but it is the best way I know to reduce filesize (About 10% usually) without sacrificing even any quality at all.
To give googler's some perspective on this, here are the facts:
There is no core Rails function to achieve this with assets
There are ways to achieve it with uploaded images
The problem you have is that since assets are manually added to Rails, there's no pre-processing you can do. If you wanted to optimize images for different environments, you'd have to create different resolutions of the images, and then use some logic to define them:
- assets
-- images
--- backgrounds
---- original.jpg
---- medium.jpg
---- small.jpg
You'd then be able to use a helper method to define the image you want:
#app/helpers/application_helper.rb
class ApplicationHelper
def size size, image
assets_path("#{File.basename(image)}/#{size.to_s}#{File.extname(image)}")
end
end
Ref: Get file name and extension in Ruby
This would allow you to call:
<%= image_tag size(:original, "backgrounds.jpg") %>
If you wanted to make this dynamic, you'd have to use CSS and set a background image, with corresponding #media queries assigning the different images as you need.
If you're talking about uploaded images, you'll be best looking into how Paperclip does it:
ImageMagick must be installed and Paperclip must have access to it. To ensure that it does, on your command line, run which convert (one of the ImageMagick utilities).
Paperclip uses ImageMagick to split images into different sizes. These are then stored in the /public/system folder, and is why you call #model.image.url(:original) when you're using it.
What I described above is basically how Paperclip works, excepting automatically using ImageMagick to make different image sizes
In Rails, while using the carrierwave gem, can we optimize images that are being uploaded? Optimize means compress and shrink the file size?
Yes, it is possible. You should write own image processor and use ImageMagick or MiniMagick command to optimize images as you wish.
For example here is article about optimization of images with MiniMagick.
The second way is related to using such gems as carrierwave-imageoptimizer it provide image optimization out of the box.