Skip to end of metadata
Go to start of metadata

What it does

I wanted a little stand alone web service that could resize, crop, and convert to black and white a library of images, on demand.

The requester will know the exact filename of the source image, but wanted the resultant image returned as the content of the http request, along with size information of the resized image.

I put together this, which seemed to work for what I wanted. Its not going to win any prizes for elegance, but it works quite reliably.

How to use

curl http://localhost:5300?file=/data/imagedata/A/M/A/B/3087&x=100&y=100&crop=1&filetype=TIFF'

Parameters

  • file Filename (as seen by the server!) of the image to scale
  • x Width of Required Image
  • y Height of Required Image
  • crop=1 Crop the image after resizing
  • bw=1 Convert image to greyscale
  • dull=n Reduce contrast of image n times
  • filetype=x Make output filetype x (see list at: http://www.imagemagick.org/script/formats.php)

If you don't specify one of x or y then the image will be resized keeping its proportions.

The crop parameter works by reducing the size of the image in proportion to either the width or the height, then crops the image along the other dimension. This allows for making square thumbnails from either portrait or landscape images. It crops from the top or left.

Labels: