View on GitHub


Test Coverage
# URL Options

This document lists and describes the full list of options available to be passed as parameters in the URL.

For server options check the [server options](/docs/

The server is setup to perform operations based on the following URL pattern.


for example:


Explanation from end-to-begining 

## path_to_image

It's the first operation the server does, it will try to get an image from the URI in the path, it can be relative to the local server, or absolute to the internet.

**example:** ``


# image_options

Here you set all the transformations and output settings you want to apply to the image you are fetching.

Most of these options are ImageMagick flags, many can get pretty advanced, use the [ImageMagick docs]( 
We put a lot of defaults in place to prevent distortion, bad quality, weird cropping and unwanted paddings. 

The script **does a lot of sanitizing** of the parameters, so many options will not work or have to be carefullly escaped. Priority is given to safety and eas of use.

## Basic geometry

### `w` : width
*Default:* `null`
*Description:* Sets the target width of the image. If not set, width will be calculated in order to keep aspect ratio.


`w_100` :   ``


### `h` : height
*Default:* `null`
*Description:* Sets the target height of the image. If not set, height will be calculated in order to keep aspect ratio.


`h_100`  : ``

### Using width AND height

By default setting width and height together, works like defining a rectangle that will define a **max-width** and **max-height** and the image will scale propotionally to fit that area without cropping.
<!-- in the future put example images here-->

By default; width, height, or both will **not scale up** an image that is smaller than the defined dimensions.
<!-- in the future put example images here-->

`h_300,w_300` : `,w_300/`


### `c` : crop
*Default:* `false`
*Description:* When both width and height are set, this allows the image to be cropped so it fills the **width x height** area.


`c_1,h_400,w_400` : `,h_400,w_400/`


### `g` : gravity
*Default:* `Center`
*Description:* When crop is applied, changing the gravity will define which part of the image is kept inside the crop area.
The basic options are: `NorthWest`, `North`, `NorthEast`, `West`, `Center`, `East`, `SouthWest`, `South`, `SouthEast`.


### `r` : rotate
*Default:* `null`
*Description:* Apply image rotation (using shear operations) to the image. 

**example: `r_90`, `r_-180`,...**

`r_45` :  `,w_400,h_400/`



## Output file formats

### `o` : output
*Default:* `auto`
*Description:* Output format requested, for example you can force the output as jpeg file in case of source file is png. The default `auto` will try to output the best format for the requesting browser, falling back to the same format as the source image or finally with a fallback to **jpg**.

If `input` is passed, no "optimal" format will be attempted. Flyimg will try to respond with the source format or fallback to `jpg`.


### `q` : quality
`int` (0-100)
*Default:* `90`
*Description:* Sets the compression level for the output image. Your best results will be between **70** and **95**.


`q_30`  :  `,w_600/` 


`q_100`  :  `,w_600/`


### `webpl` : webp-lossless
*Default:* `0`
*Description:* If output is set to webp, it will default to lossy compression, but if you want lossless webp encoding you have to set it to 1.



## Refresh or re-fetch source image

### `rf` : refresh
*Default:* `false`
*Description:* When this parameter is 1, it will force a re-request of the original image and run it throught the transformations and compression again. It will delete the local cached copy.


The nginx server will send headers to prevent caching of this request.

It will also send headers with the command done on the image + info returned by the command identity from Imagemagik.


## Fancy options

### `bg` : background
`color` (multiple formats)
*Default:* `null`
*Description:* Sets the background of the canvas for the cases where padding is added to the images. It supports hex, css color names, rgb. 
Only css color names are supported without quotation marks.
For the hex code, the hash `#` character should be replaced by `%23` 


  [...] -background red ...
  [...] -background "#ff4455" -> "%23ff4455"
  [...] -background "rgb(255,120,100)" ...



### `st` : strip
*Default:* `1`
*Description:* removes exif data and additional color profile. Leaving your image with the default sRGB color profile.


### `rz` : resize
`int` *Default:* `null`
*Description:* The alternative resizing method to -thumbnail.


### `moz` : mozjpeg
*Default:* `1`
*Description:* Use moz-jpeg compression library, if `0` it fallsback to the default ImageMagick compression algorithm.

### `unsh` : unsharp
*Default:* `null`
*Description:* Sharpens an image (despite the unfortunate naming). It basically sharpens via subtracting a blurred, low contrast, version of the image to the image itself. For more details check [Imagemagick docs](

**example 1:`unsh_0x6`**  
**example 2:`unsh_0.25x0.25+8+0.065`**

### `sh` : sharpen
*Default:* `null`
*Description:* Use a Gaussian operator of the given radius and standard deviation (sigma). For more details check [Imagemagick docs](

**example 1:`sh_3`**  
**example 2:`sh_0x5`**

### `blr` : blur
*Default:* `null`
*Description:* Apply Blur on a image. For more details check [Imagemagick docs](

**example 1:`blr_2`**  
**example 2:`blr_1x2`**

### `f` : filter
*Default:* `Lanczos`
*Description:* Resizing algorithm, Triangle is a smoother lighter option


### `sc` : scale
*Default:* `null`
*Description:* The "-scale" resize operator is a simplified, faster form of the resize command. Useful for fast exact scaling of pixels.


### `fc` : face-crop
*Default:* `0`
*Description:* Using [facedetect]( repository to detect faces and passe the coordinates to ImageMagick to crop.


`fc_1` :  ``


### `fcp` : face-crop-position
*Default:* `0`
*Description:* When using the Face crop option and when the image contain more than one face, you can specify which one you want get cropped


`fcp_2` : `,fcp_2/`


### `fb` : face-blur
*Default:* `0`
*Description:* Apply blur effect on faces in a given image


`fb_1`  : ``


### `e` : extract
#### `p1x` : extract-top-x
#### `p1y` : extract-top-y
#### `p2x` : extract-bottom-x
#### `p2y` : extract-bottom-y
*Default:* `null`

*Description:* Extract and crop an image with given the x/y coordinates of each booth top and bottom.

### `sf` : sampling-factor
*Default:* `1x1`
*Description:* ...

### `ett` : extent
*Default:* `null`
*Description:* ... not ready

### `par` : preserve-aspect-ratio
*Default:* `1`
*Description:* If set to 0, when passing width and height to an image, the image will be distorted to fill the size of the rectangle defined by width and height.

### `pns` : preserve-natural-size
*Default:* `1`
*Description:* If set to 0 and if the source image is smaller than the target dimensions, the image will be stretched to the target size.

### `gf` : gif-frame
*Default:* `0`
*Description:* ...


# process-type: *upload* or *path*

There are 2 main proceses you can do for images.

The first: **upload**, grabs an image from a URL, transforms it, saves it, and serves it, as an image, with all the apropiate headers.

The second: **path**, grabs an image from a URL, transforms it, saves it, and returns the absolute path to the image as a string, in the body of the response.


## Options keys

  moz: mozjpeg
  q: quality
  o: output
  unsh: unsharp
  fc: face-crop
  fcp: face-crop-position
  fb: face-blur
  w: width
  h: height
  c: crop
  bg: background
  st: strip
  rz: resize
  g: gravity
  f: filter
  r: rotate
  sc: scale
  sf: sampling-factor
  rf: refresh
  ett: extent
  par: preserve-aspect-ratio
  pns: preserve-natural-size
  webpl: webp-lossless

## Default options values

  mozjpeg: 1
  quality: 90
  output: auto
  unsharp: null
  face-crop: 0
  face-crop-position: 0
  face-blur: 0
  width: null
  height: null
  crop: null
  background: null
  strip: 1
  resize: null
  gravity: Center
  filter: Lanczos
  rotate: null
  scale: null
  sampling-factor: 1x1
  refresh: false
  extent: null
  preserve-aspect-ratio: 1
  preserve-natural-size: 1
  webp-lossless: 0