Imgproxy does one thing, and it does it well: resizing of remote images. It works great when you need to resize some images on the fly to make them look good on your web page. The main principles of Imgproxy are simplicity, speed, and security.
One of the things I believe in is: "The best feature is the one you don't need to implement." That's why I implemented only features that most of us need.
Imgproxy uses probably the most efficient image processing library - libvips. It's fast and requires low memory footprint. Thus it allows processing a massive amount of images on the fly.
Also, imgproxy uses native Go's net/http routing for an absolute speed.
#### Security
Processing of remote images is a quite vulnerable thing. There are many ways to attack you, so it's a good idea to take measures to prevent attacks. There is what imgproxy does:
* It checks image type and dimensions while downloading, so the image won't be fully downloaded if it has an unknown format or too big dimensions. Thus imgproxy protects you from image bombs like https://www.bamsoftware.com/hacks/deflate.html
* Imgproxy protects its URL path with a signature, so it can't be easily compromised by an attacker. Thus imgproxy doesn't allow to use itself by third-party applications.
* Imgproxy supports authorization by HTTP header. This prevents using imgproxy directly by an attacker but allows to use it through CDN or a caching server.
*`sm` - smart. Vips detects the most interesting section of the image and considers it as the center of the result image. **Note:** This value applicable only to the crop resizing.
This param is `0`, imgproxy won't enlarge image if it's smaller that given size. With any other value imgproxy will enlarge image.
#### Encoded url
The source url should be encoded with url-safe base64. Encoded url can be splitted with `/` for your needs.
#### Extension
Extension specifies the format of the result image. Imgproxy supports only `jpg` and `png` as the most popular web-image formats.
#### Signature
Signature is a url-safe base64-encoded HMAC digest of the rest of the path including leading `/`.
* Take the path after signature - `/%resizing_type/%width/%height/%gravity/%enlarge/%encoded_url.%extension`;
* Add salt to the beginning;
* Calc HMAC digest using SHA256;
* Encode the result with url-secure base64.
You can find code snippets in the `examples` folder.
## Source images formats support
Imgproxy supports only three most popular images formats: PNG, JPEG and GIF.
**Known issue:** Libvips may not support some kinds of JPEG, if you met this issue, you may need to build libvips with ImageMagick or GraphicMagick support. See https://github.com/jcupitt/libvips#imagemagick-or-optionally-graphicsmagick
## Special thanks
Special thanks to [h2non](https://github.com/h2non) and all authors and contributors of [bimg](https://github.com/h2non/bimg).