The Dynamic Image Application
- Overview of the Dynamic Image API
- Quick start
- Application Settings
- Creating mockups
- Imposition Tutorial
API Overview
API Reference
Dynamic Image APi
Security
API security key
apiKey | API Key |
---|---|
Description | API Key Authentication for /api/results/delete |
Name | API security key |
In | X-DynamicImageApiKey |
/api/Info
GET
Summary:
Returns the version, build date, build configuration, and application name.
Description:
Request Example:
$.ajax({
url: "http://localhost:84/api/info",
type: "GET",
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
Responses
Code | Description | Schema |
---|---|---|
200 | Returns the build info | BuildInfo |
500 | Server Error |
/api/resources/fonts
GET
Summary:
Returns a list of available fonts and their properties.
Description:
Request Example:
http://localhost:84/api/resources/fonts
Every element in the resulting list contains a full name, a font style, a font family, and a postScript name that you can use for personalization.
Responses
Code | Description | Schema |
---|---|---|
200 | Returns a font list | FontList |
500 | Server Error |
/api/resources/fonts/reload
POST
Summary:
Reloads fonts.
Description:
Request Example:
$.ajax({
url: "http://localhost:84/api/resources/fonts/reload",
type: "POST",
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
This endpoint scans the folder defined as the FontPath
in AppSettings.config
. After you have changed fonts in this folder, you should reload the font list to apply changes to the web service.
NOTE: If you have changed the FontPath
parameter, you must recycle the app pool.
Responses
Code | Description |
---|---|
200 | Reloads the fonts |
500 | Server Error |
/api/resources/images
GET
Summary:
Returns a list of images placed on the server and available for personalization.
Description:
Request Example:
http://localhost:84/api/resources/images?showSubfolders=true
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
subfolder | query | Specifies a folder where this endpoint obtains the image list. By default, this is an empty string, which means that this method looks for images in the folder defined as the ImagePath in AppSettings.config . |
No | string |
showSubfolders | query | Allows you to list images in subfolders. By default, this is false , which means that this method looks for images in the current folder only. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns an image list | ImageList |
500 | Server Error |
/api/resources/images/
POST
Summary:
Uploads images to the server.
Description:
Request Example:
<input type="file" class="inputfile" name="logo" id="logo" placeholder="Company Logo" onchange="uploadLogo(event)" />
...
function uploadLogo(e) {
var formData = new FormData();
var file = $('#logo')[0].files[0];
formData.append('file', file);
if (file) {
$.ajax({
url: 'https://localhost:84/api/resources/images?destination=uploaded',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(d) {
console.log(d[0].previewUrl);
},
error: function(d) {
console.error(d.responseText);
}
});
}
}
You can also pass a number of files as multipart/form-data
in this request payload.
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
destination | path | A destination subfolder. If this is a new subfolder, it will be created. By default, this is an empty string, which means that images will be uploaded to the folder defined as the ImagePath in AppSettings.config . |
Yes | string |
overwrite | query | If true , overwrites the image if its file name already exists. By default, this is false , which means that the name of the uploaded file is changed by adding _1, _2, etc. to it. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Uploads images to the server | [ ImageModel ] |
500 | Server Error |
/api/resources/images/preview
GET
Summary:
Returns an image preview.
Description:
You can use this method to obtain the content of IMG elements as follows:
<img src="http://example.com/api/resources/images/preview?file=rose.jpg&height=400" />
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
model.file | query | The image file name. | Yes | string |
model.format | query | The output file format. The default value is "jpg" . |
No | string |
model.jpegQuality | query | The quality of JPEG files, in the range [0,100]. The default value is 85 . |
No | integer |
model.width | query | The image width, in pixels. The default value is 400 . |
No | integer |
model.height | query | The image height, in pixels. The default value is 400 . |
No | integer |
model.disableCache | query | If true , renders a preview every time you make requests. By default, this is false , which means that repeated requests return the link to the already cached image. |
No | boolean |
model.unsharpMask | query | Defines whether to make an image look sharper. If false , disables this feature. To configure sharpness, define a string with parameters. The default value is "(1.2, 0.5, 0.05)" . See more details. |
No | object |
Responses
Code | Description |
---|---|
200 | Returns a file stream |
500 | Server Error |
/api/information/template
POST
Summary:
Returns information about a PSD template.
Description:
Request Example:
var model = {
"template": "badge",
"fullInfo": false
};
$.ajax({
url: "http://localhost:84/api/information/template",
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(model),
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
In the request response, you will get a JSON with info about the template. For example:
{
"size": {
"width": 800,
"height": 640
},
"layers": [
{
"name": "Photo",
"type": "Image"
},
{
"name": "Name",
"type": "Text"
}
]
}
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
model | body | A JSON object that defines the file name. | Yes | InformationTemplateModel |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns template details | FramesInfo |
500 | Server Error |
/api/rendering/preview
POST
Summary:
Renders a PSD template and returns a URL to display the preview in a browser.
Description:
Request Example:
var data = {
template: "games.psd",
format: "png"
};
$.ajax({
url: "http://localhost:84/api/rendering/preview",
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(data),
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
Response Example:
"http://localhost:84/api/results/download/1f78f1d8-cf23-45a0-ac47-ef57774cd435.png/"
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
model | body | Rendering parameters | Yes | PreviewModel |
disableCache | query | Enables rendering and loading assets every time you make requests. By default, this is false , which means that repeated requests return the link to the already cached image. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns a link to the rendered preview | string |
500 | Server Error |
/api/rendering/hires
POST
Summary:
Renders a PSD template and returns a URL that links to the print-ready PDF file.
Description:
Request Example:
var payload = {
template: "games.psd",
data: {
Team: {
type: "text",
text: "Washington Capitals"
}
}
};
$.ajax({
url: "http://localhost:84/api/rendering/hires",
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(payload),
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
Response Example:
"http://localhost:84/api/results/download/d8040e7e-53ed-406e-aef6-15e41b39a5c2.pdf/"
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
model | body | Rendering parameters | Yes | HiresModel |
disableCache | query | Enables rendering and loading assets every time you make requests. By default, this is false , which means that repeated requests return the link to the already cached image. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns a link to the print file | string |
500 | Server Error |
/api/rendering/multipage/preview
POST
Summary:
Generates preview images for several PSD files to display them in a browser.
Description:
In the request payload, this request accepts the pages
array defining parameters to render several PSD file.
Request Example:
var model = {
"pages": [
{
"template": "calendar-sample"
},
{
"template": "games.psd",
"format": "png"
}
]
};
$.ajax({
url: "http://localhost:84/api/rendering/multipage/preview",
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(model),
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
In the request response, you will get a JSON with an array of links to the rendered previews. For example:
{
"results": [
{
"url": "http://localhost:17395/api/results/download/?file=AA4A29399EC558951129149939092EE0.jpeg"
},
{
"url": "http://localhost:17395/api/results/download/?file=C71143396DE51525457F1020170EB29D.png"
}
]
}
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
model | body | A JSON object that contains a pages array with rendering parameters for several PSD files. |
Yes | MultipagePreviewModel |
disableCache | query | Enables rendering and loading assets every time you make requests. By default, this is false , which means that repeated requests return the link to the already cached image. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns links to rendered images | MultipageRenderingResponseModel |
500 | Server Error |
/api/rendering/multipage/hires
POST
Summary:
Renders several PSD files and generates a multi-page PDF file of print-ready images.
Description:
In the request payload, this request accepts the pages
array defining parameters to render several PSD file.
Request Example:
var model = {
"pages": [
{
"template": "calendar-sample"
},
{
"template": "games"
}
]
};
$.ajax({
url: "http://localhost:84/api/rendering/multipage/hires",
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(model),
success: function(d) {
console.log(d);
},
error: function(d) {
console.error(d.responseText);
}
});
In the request response, you will get a JSON with an array of one or more links to print files. For example:
{
"results": [
{
"url": "http://localhost:17395/api/results/download/?file=16D258EB44FBD814100DBCFCA90BD64B.pdf"
}
]
}
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
model | body | A JSON object that contains a pages array with rendering parameters for several PSD files. |
Yes | MultipageHiresModel |
disableCache | query | Enables rendering and loading assets every time you make requests. By default, this is false , which means that repeated requests return the link to the already cached image. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns links to rendered images | MultipageRenderingResponseModel |
500 | Server Error |
/api/results/download/
GET
Summary:
Returns a file stream or an error if the file does not exist.
Description:
Request Example:
http://localhost:84/api/results/download?file=065F92ED8B5D750AF7E2FAF8261FA05B.jpg
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
file | path | The file name. | Yes | string |
Responses
Code | Description |
---|---|
200 | Returns a file stream |
500 | Server error |
/api/results/delete/
DELETE
Summary:
Delete result file. Requires X-DynamicImageApiKey
header.
Description:
Request Example:
const url = 'http://localhost:84/api/results/delete?file=file.pdf';
const response = await fetch(url, {
method: 'DELETE',
headers: {'X-DynamicImageApiKey': 'UniqueApiKey'}
});
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
file | path | The file name. | Yes | string |
Responses
Code | Description |
---|---|
200 | File deleted |
403 | Authentication error |
500 | Server error |
/api/resources/templates
GET
Summary:
Returns a list of templates stored on the server.
Description:
Request Example:
http://localhost:84/api/resources/templates?showSubfolders=true
Parameters
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
subfolder | query | A folder where this endpoint obtains the template list. By default, this is an empty string, which means that this method looks for templates in the folder defined as the TemplatePath in AppSettings.config . |
No | string |
showSubfolders | query | If true lists templates in subfolders. By default, this parameter is false , and this method looks for images in the current folder only. |
No | boolean |
Responses
Code | Description | Schema |
---|---|---|
200 | Returns a template list | TemplateList |
500 | Server Error |
Models
BuildInfo
Application details.
Name | Type | Description | Required |
---|---|---|---|
version | string | The build version. | No |
buildDate | string | The build date. | No |
configuration | string | The build configuration. | No |
appName | string | The application name. | No |
FontList
A list of available fonts.
Name | Type | Description | Required |
---|---|---|---|
total | integer | The number of items in the list. | No |
items | [ FontInfo ] | The list of items. | No |
FontInfo
Name | Type | Description | Required |
---|---|---|---|
fullName | string | No | |
style | string | No | |
family | string | No | |
postscriptName | string | No |
ImageList
A structure containing a list of images on the server.
Name | Type | Description | Required |
---|---|---|---|
total | integer | The number of images in the list. | No |
items | [ ImageModel ] | The list of images. | No |
ImageModel
A structure containing a title, file name, and URL to preview an image on the server.
Name | Type | Description | Required |
---|---|---|---|
title | string | The image title. | No |
name | string | The file name. | No |
previewUrl | string | A URL to preview the image. | No |
ImagePreviewModel
Image preview parameters.
Name | Type | Description | Required |
---|---|---|---|
file | string | The image file name. | Yes |
format | string | The output file format. The default value is "jpg" . |
No |
jpegQuality | integer | The quality of JPEG files, in the range [0,100]. The default value is 85 . |
No |
width | integer | The image width, in pixels. The default value is 400 . |
No |
height | integer | The image height, in pixels. The default value is 400 . |
No |
disableCache | boolean | If true , renders a preview every time you make requests. By default, this is false , which means that repeated requests return the link to the already cached image. |
No |
unsharpMask | object | Defines whether to make an image look sharper. If false , disables this feature. To configure sharpness, define a string with parameters. The default value is "(1.2, 0.5, 0.05)" . See more details. |
No |
InformationTemplateModel
Name | Type | Description | Required |
---|---|---|---|
template | string | The file name of a PSD template (required). | Yes |
fullInfo | boolean | If true , returns the full information about the template and its design elements. If false , returns the template size and a list of names and types of design elements. The default value is false . |
No |
FramesInfo
Name | Type | Description | Required |
---|---|---|---|
size | Size | The image size. | No |
layers | [ BaseLayer ] | An array of layers in a PSD file. | No |
Size
Defines an image width and height.
Name | Type | Description | Required |
---|---|---|---|
width | integer | The image width. | No |
height | integer | The image height. | No |
BaseLayer
Name | Type | Description | Required |
---|---|---|---|
name | string | The layer name. | No |
type | string | The layer type. | No |
PreviewModel
Parameters for rendering previews.
Name | Type | Description | Required |
---|---|---|---|
format | string | The output file format. The default value is "jpg" . |
No |
size | object | The image size, in pixels. By default, it is {'width': 800, 'height': 800} . |
No |
jpegQuality | integer | The quality of JPEG files, in the range [0,100]. The default value is 85 . |
No |
optimizePreview | boolean | Enables optimization of preview images. | No |
unsharpMask | object | Defines whether to make an image look sharper. If false , disables this feature. To configure sharpness, define a string with parameters. The default value is "(1.2, 0.5, 0.05)" . See more details. |
No |
template | string | The file name of a PSD template (required). | Yes |
data | object | The personalization data. | No |
preloadImages | boolean | Makes the rendering process faster. If true , preloads the external images before rendering. The default value is false . |
No |
HiresModel
Parameters for rendering print files.
Name | Type | Description | Required |
---|---|---|---|
template | string | The file name of a PSD template (required). | Yes |
data | object | The personalization data. | No |
preloadImages | boolean | Makes the rendering process faster. If true , preloads the external images before rendering. The default value is false . |
No |
MultipagePreviewModel
Parameters for rendering a number of PSD files.
Name | Type | Description | Required |
---|---|---|---|
pages | [ PreviewModel ] | An array of definitions of preview images. | No |
MultipageRenderingResponseModel
Links to rendering results.
Name | Type | Description | Required |
---|---|---|---|
results | [ RenderingResponseModel ] | No |
RenderingResponseModel
Name | Type | Description | Required |
---|---|---|---|
url | string | No |
MultipageHiresModel
Parameters for rendering a number of PSD files.
Name | Type | Description | Required |
---|---|---|---|
combine | boolean | If true , combines print-ready images into one multi-page PDF file. If false , generates a separate PDF file for each template. The default value is true . |
No |
pages | [ HiresModel ] | An array of definitions of preview images. | No |
TemplateList
A list of available templates.
Name | Type | Description | Required |
---|---|---|---|
total | integer | The number of items in the list. | No |
items | [ string ] | The list of items. | No |