Skip to content

argh/mkimage-server

Repository files navigation

mkimage-server

On-demand image resize server based on 'express'. Heavily modified from the original Boxee code by CreativeLive over the years. Most information in this file is obsolete; the server typically is run in a Docker container now. (Repo archived for posterity, will need build process tweaking to excise old CreativeLive internal references to be usable.)

Installation & running

1: assuming you have proper node 0.8.x installed

2: user that runs the server is 'mkimage'

3: set desired settings in config directory

# install imagemagick
sudo apt-get install --no-install-recommends build-essential imagemagick

# clone the repo
git clone git://github.com/Boxee/mkimage-server.git

# install node dependencies
cd mkimage-server && npm install

# create `cache_dir`
mkdir -p /mnt/cache/mkimage-server
chown mkimage.mkimage /mnt/cache/mkimage-server

# run it (in production)
NODE_ENV=production bin/mkimage

Basic usage

  • url - the url of remote image to be converted (and cached)
  • w - width of resized image
  • h - height of resized image
  • q - quality of resized image (default is 92)

the url parameter must be encoded, otherwise unexpected behaviour may occur.

  • the url http://www.google.com/images/icons/product/apps-128.png
  • becomes http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png

Note: lib/oldapi.js is actually the new API, don't let it fool you.

Examples

# resize an image with keeping ratio (width)
# /fit/{url}/{width}/{height?}
http://example.com/fit/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/200

## resize an image with keeping ratio (width) and changing image quality (use q as a query param)
# /fit/{url}/{width}?q={quality}
http://example.com/fit/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/200?q=60

# resize an image with keeping ratio (width & height)
http://example.com/fit/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/100/200

# resize an image to given size without keeping the ratio
# /fill/{url}/{width}/{height}
http://example.com/fill/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/200/200

# very basic crop for now, will add more options in future
# /crop/{url}/{width}/{height}/{xOffset}/{yOffset}
http://example.com/crop/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/200/200/50/50

# a centered chop, shrink & crop cutting off edges - good for square thumbnails...
# /chop/{url}/{width}/{height}
http://example.com/chop/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/100/100

# return resized/cropped/etc. image in webp format
# /{method}/{url}/webp/{width}/{height?}/{xOffset?}/{yOffset?}
http://example.com/fit/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/webp/200
http://example.com/crop/http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png/webp/200/200/50/50

Old API

# resize an image with keeping ratio (width)
http://example.com/resize?url=http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png&w=200

# resize an image with keeping ratio (height)
http://example.com/resize?url=http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png&h=200

# resize an image to given size without keeping the ratio
http://example.com/stretch?url=http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png&w=200&h=200

# crop an image from the CENTER (height is optional),
# very basic crop for now, will add more options in future
http://example.com/crop?url=http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png&w=200

# return image with same size as original (just cache it)
http://example.com/cache?url=http%3A%2F%2Fwww.google.com%2Fimages%2Ficons%2Fproduct%2Fapps-128.png

More docs coming soon

About

On-demand image resize server based on 'express'

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors