https://github.com/cobusc/imagerl
Image renderer and cacher in Erlang
https://github.com/cobusc/imagerl
cacher erlang image imagemagick s3
Last synced: 11 months ago
JSON representation
Image renderer and cacher in Erlang
- Host: GitHub
- URL: https://github.com/cobusc/imagerl
- Owner: cobusc
- Created: 2013-04-05T14:09:09.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2014-05-02T12:51:52.000Z (about 12 years ago)
- Last Synced: 2023-03-23T13:10:08.489Z (over 3 years ago)
- Topics: cacher, erlang, image, imagemagick, s3
- Language: Erlang
- Size: 3.46 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# imagerl [](https://travis-ci.org/cobusc/imagerl)
Image renderer and cacher in Erlang. It supports:
* resizing based on the device size (using WURFL Cloud to perform lookups),
* image convertion using the `convert` utility provided by ImageMagick,
* serving of locally hosted images using the `file://` scheme, and
* serving of Amazon S3 (privately) hosted images using the `s3:///` scheme, which builds the required signed URL.
Quick usage guide
=================
Cache and serve an image
------------------------
If the image is located at "http://www.google.co.za/images/srpr/logo3w.png", make the following call:
```
http://localhost:8000/render?url=http%3A%2F%2Fwww.google.co.za%2Fimages%2Fsrpr%2Flogo3w.png
```
The image will be retrieved, cached and served the first time it is request. Thereafter it will simply be served from the cache.
Note that:
* Local files can be served using the "file://" scheme.
* Files hosted on Amazon S3 can be served using the `s3://` scheme.
* Source image caching can be disabled in the config file if necessary.
Restrict the width or height
----------------------------
If you require the image to have a restricted width or height, it can be specified:
```
http://localhost:8000/render?url=http%3A%2F%2Fwww.google.co.za%2Fimages%2Fsrpr%2Flogo3w.png&width=100
```
or
```
http://localhost:8000/render?url=http%3A%2F%2Fwww.google.co.za%2Fimages%2Fsrpr%2Flogo3w.png&height=100
```
The aspect ratio will be preserved in this case.
The `width` or `height` values may be set to `wurfl`, in which case a WURFL lookup will be performed using the specified `ua` argument, or the detected device. Opera Mini's custom user agent header is supported.
Resize an image to specific dimensions
--------------------------------------
If you need to resize the image to specific dimensions, specify BOTH the width and the height:
```
http://localhost:8000/render?url=http%3A%2F%2Fwww.google.co.za%2Fimages%2Fsrpr%2Flogo3w.png&width=100&height=100
```
Annotate the image with text
----------------------------
Text can be annotated diagonally across the image by adding "annotation=", e.g.
```
http://localhost:8000/render?url=http%3A%2F%2Fwww.google.co.za%2Fimages%2Fsrpr%2Flogo3w.png&annotation=SAMPLE
```
Debugging
---------
For debugging purposes the following additional arguments have been exposed:
* `nocache` - Forces the imager to retrieve the specified image from the source and repopulate the cached copy, rather than use the cached copy.
* `debug` - Enables detailed debug logging for the request.
User interface
==============
A graphical user interface is available at
```
http://localhost:8000/ui
```
Notes to self...
================
Check out
```
http://www.imagemagick.org/Usage/annotating/
```
Some notes from the Imagick website relating to geometry specifications...
sizeGeneral description (actual behavior can vary for different options and settings)
scale%Height and width both scaled by specified percentage.
scale-x%xscale-y%Height and width individually scaled by specified percentages. (Only one % symbol needed.)
widthWidth given, height automagically selected to preserve aspect ratio.
xheightHeight given, width automagically selected to preserve aspect ratio.
widthxheightMaximum values of height and width given, aspect ratio preserved.
widthxheight^Minimum values of width and height given, aspect ratio preserved.
widthxheight!Width and height emphatically given, original aspect ratio ignored.
widthxheight>Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s).
widthxheight<Enlarges an image with dimension(s) smaller than the corresponding width and/or height argument(s).
area@Resize image to have specified area in pixels. Aspect ratio is preserved.