Web Technologies

Thumbor

In many situations developers need to show the thumbnail images which are stored in the database. But they can’t do it like streaming the original image and resize it with applying CSS. It will cost lot of data and memory consumption. For the solution of that we are using thumbor.

Thumbor is a smart imaging service which provide cropping, resizing and flipping of images. It uses more advanced algorithms to detect the image parts to better cropping and resizing.

Prerequisite
The stable version of thumbor is associate with the Python Package Index. So that python needed to be installed before thumbor.For installing python first you have to get compressed file of python to your server.
wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz
Then decompress the file by using
tar xvzf Python-3.4.3.tgz
Now the python can be installed by going to the directory and using following commands.
cd Python-3.4.3
./configure --prefix=$HOME/.local
make
make install
Installation of thumbor
If you want thumbor to resize the image within the safe environment simply you can install it in your own server using following command
pip install thumbor
The thumbor service can be run just by typing
thumbor
For constant running of thumbor use
nohup thumbor &
Resize image
After the successful installation of the thumbor the image can be edited just by using the server url, port and the image url. For example

https://127.0.0.1:8888/unsafe/150×150/https://[email protected]/image.jpg

(replace 127.0.0.1 with server ip address)

By default the thumbor running in the port 8888.The 150×150 tells the thumbor that height and width of the image should be 150.And finally the url of the image.The thumbor will resize and will returns the image with given height and width.

Change background color


The thumbor can change the background color of the image just by giving the filters along with the url.

http://127.0.0.1:8888/unsafe/filters:background_color(blue)/https://[email protected]/image.jpg

Change RGB value


The image rgb value can be changed by providing the values with the url

http://127.0.0.1:8888/unsafe/filters:rgb(20,-20,40)/https://[email protected]/image.jpg

Conclusion


The thumbor can do more like change the image brightness, contrast, blur the image and a lot. For detail reference about thumbor please visit here.

Author


Avatar