Devesprit.ImageProcessor & Devesprit.ImageServer
Resize

Description:

Resizes the current image to the given dimensions.

Devesprit.ImageServer allows you to scale images both up and down with an excellent quality to size ratio. A maximum width and height can be set in the configuration to help protect you from DoS attacks.

Parameters:

Six different types of resizing methods are available:

All image requests allow up scaling by default. A limiter is set in the processing.config file to help prevent DoS attacks.

To turn off up scaling simply append the value upscale=false to your request Url. (This does not affect stretched, boxpad, nor min modes).

Resize Pad

Passing a single dimension will automatically preserve the aspect ratio of the original image. If the requested aspect ratio is different then the image will be padded to fit. Widths and heights can optionally also be passed as a ratio. You can recolor the background color of the padded area for image types without transparency from the default black.

Pad mode also offers optional anchor positions:

Example:

Automatic height based on width:

http://your-host/images/picture?width=600

Automatic width based on height:

http://your-host/images/picture?height=250

Both dimensions specified:

http://your-host/images/picture?width=600&height=250

Both dimensions specified with the image anchored to the top:

http://your-host/images/picture?width=600&height=250&anchor=top

Height ratio passed for automatic scaling:

http://your-host/images/picture?width=600&heightratio=0.416

Width ratio passed for automatic scaling:

http://your-host/images/picture?widthratio=2.4&height=250

Background color added to padded image:

http://your-host/images/picture?width=600&height=250&bgcolor=fff

Resize BoxPad

When up scaling an image the image pixels themselves are not resized, rather the image is padded to fit the given dimensions. When downscaling the image is resized using the rules defined by ResizeMode.Pad. You can recolor the background color of the padded area for image types without transparency from the default black.

BoxPad mode also offers optional anchor positions:

Example:

Automatic height based on width:

http://your-host/images/picture?width=600&mode=boxpad

Automatic width based on height:

http://your-host/images/picture?height=250&mode=boxpad

Both dimensions specified:

http://your-host/images/picture?width=600&height=250&mode=boxpad

Both dimensions specified with the image anchored to the top:

http://your-host/images/picture?width=600&height=250&anchor=top&mode=boxpad

Height ratio passed for automatic scaling:

http://your-host/images/picture?width=600&heightratio=0.416&mode=boxpad

Width ratio passed for automatic scaling:

http://your-host/images/picture?widthratio=2.4&height=250&mode=boxpad

Background color added to padded image:

http://your-host/images/picture?width=600&height=250&mode=boxpad&bgcolor=fff

Resize Crop

Resizes the image to the given dimensions. If the set dimensions do not match the aspect ratio of the original image then the output is cropped to match the new aspect ratio.

Crop mode also offers optional anchor positions:

You may specify a center as a fraction from the left and top. Fractions are specified as a decimal between 0 and 1. This point will be as close to the center of your crop as possible while keeping the crop within the image.

Example:

Standard:

http://your-host/images/picture?width=300&height=300&mode=crop

Crop anchored to the top:

http://your-host/images/picture?width=300&height=300&mode=crop&anchor=top

Center:

http://your-host/images/picture?width=300&height=300&mode=crop&center=0.25,0.30

Resize Min

Resizes the image until the shortest side reaches the set given dimension. This will maintain the aspect ratio of the original image. Up Scaling is disabled in this mode and the original image will be returned if attempted.

Example:

http://your-host/images/picture?width=500&height=500&mode=min

Resize Max

Resizes the image to the given dimensions. If the set dimensions do not match the aspect ratio of the original image then the output is resized to the maximum possible value in each direction while maintaining the original aspect ratio.

Example:

http://your-host/images/picture?width=500&height=500&mode=max

Resize Stretch

Resizes the image to the given dimensions. If the set dimensions do not match the aspect ratio of the original image then the output is stretched to match the new aspect ratio.

Example:

http://your-host/images/picture?width=500&height=500&mode=stretch

Assembly:

Devesprit.ImageServer

 

Example:

Original

 

Result (http://your-host/images/picture?width=500&height=500&mode=pad)

 

Result (http://your-host/images/picture?width=500&height=500&mode=padbox)

 

Result (http://your-host/images/picture?width=500&height=500&mode=crop)

 

Result (http://your-host/images/picture?width=500&height=500&mode=min)

 

Result (http://your-host/images/picture?width=500&height=500&mode=max)

 

Result (http://your-host/images/picture?width=500&height=500&mode=stretch)