Dynamic Image Manipulation Service with Nginx
Uses the HttpImageFilterModule to dynamically process remote images into cropped, rotated and resized derivatives based on remote source images. Derivative images are created only once per unique url and stored locally. Duplicate requests are served directly from disk.
-
Launch a server, e.g. Ubuntu Server 14.04 LTS. Nothing special except you need ports 22 (to login via ssh) and 8080 to run the service.
-
SSH into the machine and run the following commands:
# When you log into the server from the terminal run these commands
sudo mkdir /mnt/media/ # Or whatever you want the server root to be
sudo chown ubuntu:ubuntu /mnt/media
chmod 777 /mnt/media
sudo apt-get install nginx-extras-dbg
# if you get an error uncomment the offending lines in this file and try to reinstall nginx again
# sudo vim /etc/apt/sources.list
curl -O https://raw.githubusercontent.com/fredpalmer/dimwit/develop/nginx.conf
sudo mv nginx.conf /etc/nginx/sites-enabled/
sudo /etc/init.d/nginx restart
That's it!
# resize example
http://<dims-host>:8080/resize/100x100/http://2.bp.blogspot.com/_nm9ySucveA8/TEYgGu9DIgI/AAAAAAAAAO4/XI1q38FFlxw/s1600/unicorns2q.jpg
# crop example
http://<dims-host>:8080/crop/200x200/http://4.bp.blogspot.com/_nm9ySucveA8/TEYgGSJi7sI/AAAAAAAAAOw/XK4VjrHPybw/s1600/unicorns-5-magical-animal.jpg
# rotate example
http://<dims-host>:8080/rotate/90/http://3.bp.blogspot.com/_nm9ySucveA8/TEYgGF9iEWI/AAAAAAAAAOo/uC62nczWcEk/s1600/unicorn1.jpg