MediaPlug
Image API

HomePage | REST API | Javascript Usage | Ruby Wrapper

Image API

Resize | Crop | | Rotate | Flip | Watermark

Resize

resize width=x height=y format=f 
x: dimension of desired width
y: dimension of desired height
f: jpg|gif|png
mpaction=resize width=200 height=100 format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=resize width=400 height=100 format=gif

The following geometry qualifiers can also be used with x and y when resizing:

% + - > < 

Increase the width by 150 pixels, and decrease the height by 30 pixels.

mpaction=resize width=+150 height=-30
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=resize width=+150 height=-30

Decrease the width to 80 percent of the original width, and increase the height to 120 precent of the original height.

mpaction=resize width=80% height=120%
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=resize width=80% height=120%

Resize the width to 100, and resize the height proportionally. So a 200×100 image will become 100×50 after this operation.

mpaction=resize width=100 height=     
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=resize width=100 height=*

Resize the width to at least 100 pixels, and resize the height to at most 50. So a 200×40 image will not change, but a 80×100 images will be resized to 100×50.

mpaction=resize width=>100 height=<50
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=resize width=>100 height=<50>

Note: ‘>’, ‘<’, and ’%’ should be encoded (to ”%3E”, ”%3C”, and ”%25”) in the url as they are HTML special characters.

Crop

crop location=l x-origin=xo y-origin=ye x-end=xe y-end=ye width=w height=h format=f
l: absolute|center
xo: integer, x-origin, the location relative to height to start the crop (can only be used with absolute location)
yo: integer, y-origin, the location relative to the width to start the crop (can only be used with absolute location)
xe: integer, x-end, the location relative to the height to end the crop (can only be used with absolute location)
ye: integer y-end, the location relative to the width to end the crop (can only be used with absolute location)
w: width to crop the resulting image (can only be used with center location)
h: heigh to crop the resulting image (can only be used with center location)
f: jpg|gif|png
mpaction=crop location=absolute x-origin=1 y-origin=10 x-end=70 y-end=70 format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=crop location=absolute x-origin=1 y-origin=10 x-end=70 y-end=70 format=gif

mpaction=crop location=center width=100 height=100 format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=crop location=center width=100 height=100 format=gif

Rotate

rotate degree=x format=f
x: degree to rotate the image
f: jpg|gif|png
mpaction=rotate degree=45 format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=rotate%20degree=45%20format=gif

Flip

flip direction=v|h|b format=f
v: vertical flip
h: horizontal flip
b: vertical and horizontal flip
f: jpg|gif|png
mpaction=flip direction=v format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=flip%20direction=v%20format=gif

mpaction=flip direction=h format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=flip%20direction=h%20format=gif

mpaction=flip direction=b format=gif
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=flip%20direction=b%20format=gif

Watermark

watermark url=u|t position=p alpha=a text-font-size=s bold=b italic=i format=f 
u: url of watermark image
t: text to watermark the image with
p: top|top-left|top-right|middle|bottom|bottom-left|bottom-right (optional, default is middle)
a: 0.0-1.0 (this specifies the transparency, optional, default is 0.6)
s: integer, size of font if using text to watermark
b: true|false (optional, default is false)
i: true|false (optional, default is false)
f: jpg|gif|png

Note: Spaces can be added to the text watermark by inserting ’\’ between words.

mpaction=watermark text=watermark\ demo format=gif position=middle alpha=0.7 text-font-size=32 bold=true italic=true           
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=watermark text=watermark\ demo format=gif position=middle text-font-size=32 alpha=0.7 bold=true italic=true

mpaction=watermark text=watermark\ demo format=gif position=bottom-right alpha=1 text-font-size=24
http://demo.gomediaplug.com/mp/get?mpsrc=http://gomediaplug.com/images/mediaplug.gif&mpaction=watermark text=watermark\ demo format=gif position=bottom-right alpha=1 text-font-size=24

Note: Image actions can be chained together by separating them with a ’;’ in the mpaction. For example mpaction=flip direction=h format=gif;rotate degree=90 format=gif will first flip the image horizontally then rotate it 90 degrees.