Automatically color balance images - ruby

Is there a way in Ruby to automatically color-balance images that are uploaded to my Ruby on Rails app?
It seems like a lot of the images I'm uploading are too dark and I'd like to normalize all my images to be equally bright if possible, rather than simply making every image brighter. If some image is sufficiently bright, it should not be changed.

I would use rmagick. Take a look at the modulate method, perhaps that would help.

Related

Best way to display 300 000+ images online?

Is there a way to display so many images ? Maybe something like google maps, that would show all images at once as tiles and you could zoom in and see the picture in detail... ?
This problem can be easily solved by merging all images side by side like a collage.
This task can be automated by using python using its pyautogui module and any simple software for image manipulation.
By doing this a single image of very high resolution can be obtained achieving your purpose.
(Although the size of the image would be mind blowing.)
See these sites for similar works (1.2 Billion images) but with smarter solution (the are loading few images at a time upon zooming).
All 1.2-Billion Facebook Profile Pictures On One Page
The Face of Facebook
Ok, it took very long time to process and finish, but I made it ! It CAN be done. correct tools are libvips and its python version pyvips I managed to get all 366 000+ pictures in one, and then made zoomable pyramid dzi with it ! To display it OpenSeadragon since the final picture was 81GB and nothing can open that.... http://deepzoom.reverz.sk/ ( also not sure why my question was down voted :-/ )

Magento Image processing extension

Is there any extension which is specifically goes for fill image color like module. I have 1000's of images which all same size but have white space around all image, instead of using photoshop can i use PHP to process that image to have different(brown color - sine it is background) instead of white. If there is any extension please suggest me.
Thanks in advance
If you want to have same background for all images,you can override the magento class that applies background color.
File is app/code/core/Mage/Catalog/Model/Product/Image.php
Find the code that looks like this protected $_backgroundColor = array(255, 255, 255); and specify the RGB value of the colour that you want.
Check out ImageMagick. I haven't used it for exactly what you are trying to do, but I have used it for other kinds of batch image processing. It can be ran from the commandline, but also has APIs for several programming languages.
For what you are trying to do, I'd take a look at the -fill, -floodfill, and -fuzz options.
http://www.imagemagick.org/script/command-line-options.php#fill
I got solution for my problem by the following method.
<?php
echo $this->helper('catalog/image')->init($_product, 'image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepFrame(FALSE)
->resize(600,null)
?>
I got it from here.
http://blog.chapagain.com.np/magento-resize-image/
You should consider getting rid of that white space unless you have other reason for it, e.g. to have product images to scale.
This is best achieved with Photoshop if you have got it, if the white is absolutely, definitely white then you can take the top-left pixel and crop from that.
Another option you may wish to consider is using png images, again this depends on your images and skill in Photoshop, however, you can use transparency in png and have no border on your images.
Also, in photoshop or imagemagick you may want to consider making your own thumbnail images, separate to the product page image. This will enable you to apply filters such as sharpen to get product page images that are a cut above your competitors.
As noted by #jmspldnl you can use imagemagick on the command line as well as php extension. On the command line you can work out the process and string together lots of steps, when happy with your options, rather than re-work it in php code you can use 'passthru()' and run what you worked out from the command line.
For going forward you can put a cron job that monitors your images folder and processes and images that have been changed/added in the last day. This will make it easier to just upload images and have your system do the work.

How does facebook handle resizing of images

Hello I am building a social network similar to facebook and I really need some help on how to handle the images in my website. I would like to know how sites like facebook manage the resizing of their images. An example would be looking at someones photo album. The length and width are not just simply changed. They are done in a more professional way to make the image still look clear and not stretched. Do they use a special tool for this. Another example would be profile pics when they are loaded to your message wall. Your friends profile pics are centered and cropped accordingly and then re sized. How do they go about doing this. Any help would be greatly appreciated.
They resize proportionally with an imaging library like GD, Imagick or others.
The presentation in the gray area is just that, presentation so HTML and CSS.
They stretch the images proportionally so that they don't look wrong; if you make the image 37.5% wider... you also make it 37.5% taller.
If we knew what language you are familiar with, we could probably suggest something to help with this.

Image processing with barehands-ruby

I want to know how to open and manipulate a simple image file in Ruby language.
I don't need to do any advanced stuff, just things like open(), get_pixel() and put_pixel() and I don't wanna use any gem for doing that, but just to know the barehands-ruby way.
If by "simple image file" you refer to JPEG, GIF or so, it's tough luck because you'd have to implement all the decoding logic, which is far from being simple (take a look here for more info, but briefly because you really don't want to go into details ;)).
After decoding, eventually what you get is a matrix (two-dimensional array) of pixel information (usually three numbers for red, green and blue component, but other options exist). Then your methods get_pixel and set_pixel are trivial.
What Ruby folks usually do in such cases is wrap already existing C library for image manipulation, into a library such as rmagick.
Paperclip + ImageMagick did the trick. It's awesome and easy

Make image transparent in ruby

I was wondering if anyone could suggest to me potential libraries in ruby for manipulating jpegs? Specifically I want to make the image 50% transparent so it can act as an overlay. The image in question would be of a house and I'd like it to overlay a village image.
Just being specific about the image as the transforms may not like multiple colours :)
Take a look at RMagick. This tutorial features transparency/opacity.
Best wishes,
Fabian
Check out RMagick

Resources