Convert your animations in four simple steps
Upload your creative as either:
Specify rendering options including:
Automatic notifications when:
Optional monitoring through our:
https://html5animationtogif.com/api/uploadzip.ashx
Upload a compressed archive containing your HTML5 creative package. Your submission must include:
A single HTML file (entry point)
All associated resources (CSS, JavaScript, and images)
Response
Upon successful upload, you'll receive a creativeid
in the response. Store this identifier for all subsequent API calls.
Alternative Submission Method
For animations hosted on your server, use our UploadUrl
service instead of zip file upload.
Parameter | Type | Required | Description |
---|---|---|---|
FileData | multi-part form data | Yes | Submit your HTML5 creative (zip) as a multi-part form data upload |
POST https://html5animationtogif.com/api/uploadzip.ashx HTTP/1.1 Host: html5animationtogif.com Content-Type: application/binary const formData = new FormData(); formData.append('file', document.querySelector('input[type=file]').files[0]); fetch('https://html5animationtogif.com/api/uploadzip.ashx', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => console.log(data));
{ "status": "success", "creativeid": "creative_550x550_10ed7e8783" } Or { "status": " error ", "message” ": "No file has been uploaded. " }
https://html5animationtogif.com/api/uploadurl.ashx
Submit a publicly accessible URL of your hosted HTML5 creative for processing.
Response
Upon successful upload, you'll receive a creativeid
in the response. Store this identifier for all subsequent API calls.
Parameter | Type | Required | Description |
---|---|---|---|
url | string | Yes | Post your HTML5 creative URL |
POST https://html5animationtogif.com/api/uploadurl.ashx HTTP/1.1 Host: html5animationtogif.com Content-Type: text/plain var data = new FormData(); data.append("url", "https://previews.envatousercontent.com/files/240056227/banners/A/728x90/index.html"); // URL of creative hosted on your server var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://html5animationtogif.com/api/uploadurl.ashx', true); xhr.onload = function () { var response = JSON.parse(xhr.responseText); if (response.status == "success") { creativeid = response.creativeid; console.log("creativeid=" + creativeid); //convert_gif(creativeid); } else { alert(response.message) }
{ "status": "success", "creativeid": "creative_550x550_10ed7e8783" } Or { "status": " error ", "message” ": "No file has been uploaded. " }
https://html5animationtogif.com/api/converttogif.ashx
Converts your HTML5 creative into gif format through asynchronous rendering.
Parameter | Type | Required | Description |
---|---|---|---|
clientid | string | Yes | A unique customer ID, generated when the 'Obtain API Key and Client ID' link is clicked, and subsequently sent via email. |
apikey | string | Yes | A unique key, generated when the 'Obtain API Key and Client ID' link is clicked, and subsequently sent via email. |
creativeid | string | Yes | The creativeId is a unique identifier returned after successfully uploading your HTML5 content through either: UploadZip or UploadUrl service. |
width | integer | Yes | Output width in pixels. |
height | integer | Yes | Output height in pixels. |
duration | float | Yes | Length of animation. |
starttime | float | No | Skips the initial few seconds of the animation before recording the gif. The default value is 0. |
loop | integer | Yes |
The loop setting determines how many times a GIF animation repeats after its first playthrough.
To create an infinite "forever" loop, use the parameter
Note: Acceptable values range from 0 to 1000. If your animation loops more than once, provide the duration of a single loop, not the total duration including all repetitions.
|
fps | integer | Yes |
Specifies the playback speed of the animation.
Note: The minimum value is 2 and the maximum is 30.
|
webhookurl | string | No |
Default value:
The webhook is a notification mechanism that allows your application to receive an update once a gif is successfully created.
To use it, provide the HTTP URL of your application via the
Example:
How to access parameters (C# example):
|
creativefitoption | string | No |
Possible values: Default value: Use Use |
encoder | string | No |
This option allows you to specify which encoder to use when creating the GIF.
Possible values: IMAGEMAGIC
A slightly slower encoder that produces GIFs with good color accuracy and optimized file size. FFMPEG
A fast encoder that generates GIFs with moderate to good quality (256 colors only) and optimized file size. GIFISKI
A high-speed encoder that produces high-quality GIFs with original or true color (32-bit), resulting in slightly larger file sizes. LWZENCODER
A fast encoder that produces GIFs with moderate to good quality (256 colors only) and optimized file size. |
quality | integer | yes |
This option specifies the quality level for the generated GIF.
Possible values:
Pass one of the above values in the request. These correspond to the following quality levels:
|
maxsize | integer | no |
Specifies the target file size for the output GIF in kilobytes (KB).
For example:
Default value:
Note: To achieve the target file size, the renderer may make multiple attempts.
It may reduce the frame rate (FPS) and quality if necessary.
Example: If you set a target file size of 150 KB with a frame rate of 5 fps , the renderer will:
|
POST https://html5animationtogif.com/api/converttogif.ashx HTTP/1.1 Host: html5animationtogif.com Content-Type: text/plain var data = new FormData(); data.append("clientid", clientid); data.append("apikey", apikey); data.append("creativeid", id); data.append("width", "300"); data.append("height", "600"); data.append("duration", "8"); data.append("fps", "12"); data.append("loop", "1"); data.append("webhookurl", ""); data.append("creativefitoption", "center"); data.append("maxsize", ""); var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://html5animationtogif.com/api/converttogif.ashx', true); xhr.onload = function () { var response = JSON.parse(xhr.responseText); if (response.status == "success") { mediaid = response.mediaid; console.log("GIF " + mediaid + "."); alert("GIF " + mediaid + "."); //WaitForOutput(); } else { alert(response.message) } }; xhr.send(data);
{ "status": "success", "message": "", " mediaid ": "34488" } Or { "status": "error", "message": "error message" }
https://html5animationtogif.com/api/checkstatus.ashx
This service allows you to check the conversion status.
It should be called after invoking the converttogif service. You can call it periodically—for example, every 5 seconds.
Parameter | Type | Required | Description |
---|---|---|---|
creativeid | string | Yes | The creativeId is a unique identifier returned after successfully uploading your HTML5 content through either: UploadZip or UploadUrl service. |
mediaid | string | Yes | The mediaid is a unique identifier returned by the ConvertToGif service. |
fileext | string | Yes | The file extension for an GIF file. (i.e gif) |
GET https://html5animationtogif.com/api/checkstatus.ashx HTTP/1.1 Host: html5animationtogif.com Content-Type: text/plain function WaitForOutput() { var xhr = new XMLHttpRequest(); xhr.open('GET', "https://html5animationtogif.com/api/checkstatus.ashx?creativeid=" + creativeid + "&mediaid=" + mediaid + "&fileext=gif", true); xhr.onload = function () { var response = JSON.parse(xhr.responseText); if (response.status == "success") { if (response.jobstatus != "done") { window.setTimeout(WaitForOutput, 5000); } else if (response.jobstatus == "done") { var URL=response.url; } } else if (response.status == "error") { alert(response.message) } }; xhr.send(); }
Parameter | Type | Description |
---|---|---|
status | string |
The
"success" - The operation completed successfully
"error" - The operation failed (check error details)
|
jobstatus | string |
The
Pending
Initial state when request is queued
XX%
Percentage complete (e.g., 25%, 50%, 75%)
Done
Processing successfully completed
Note: Percentage values may not increment linearly due to varying processing stages.
|
message | string | Indicates the error message, if any occurred during processing. |
url | string | The download URL of the generated GIF . |
Specifies, scrapping of content { “status”: "success", "jobstatus": "Scraping content. Please wait...", "url": "" } Specifies, encoding of gif { "status": "success", "jobstatus": "20%", "url": "" } { "status": "success", "jobstatus": "40%", "url": "" } { "status": "success", "jobstatus": "90%", "url": "" } Specifies, gif has been created. { "status": "success", "jobstatus": "done", "url": "https://html5animationtogif.com/API/mediadownload.ashx?mediaid=34488&creativeid=creative_550x550_10ed7e8783&fileext=gif&inline=y" }
When recording HTML5 animations to gif, two key challenges arise:
Add these JavaScript functions to your HTML5 creative:
Call this when your actual animation begins (after loaders/initialization):
function animationStart() {
// Your animation code
if (typeof trim_start === 'function') {
trim_start(); // Signals actual content beginning
}
}
Call this when your animation completely finishes:
function animationEnd() {
// Cleanup code
if (typeof trim_end === 'function') {
trim_end(); // Signals content completion
}
}
// Place the code in your JavaScript file
var trim_request_url = "http://localhost/capturestart/trim_media.ashx";
function trim_start()
{
try {
var timeinmilisec = Math.abs(new Date() - new Date("1970/01/01"));
var request = new XMLHttpRequest();
request.open('GET', trim_request_url + "?action=start&time=" + timeinmilisec, true);
request.send(null);
} catch{ }
}
function trim_end() {
try {
var timeinmilisec = Math.abs(new Date() - new Date("1970/01/01"));
var request = new XMLHttpRequest();
request.open('GET', trim_request_url + "?action=end&time=" + timeinmilisec, true);
request.send(null);
} catch{ }
}
Renderer opens HTML5 creative in browser (load time begins)
Animation calls trim_media.ashx?action=start
(3s in example)
Animation calls trim_media.ashx?action=end
(9s total in example)
Renderer records 4s extra (13s total in example
Renderer creates 6s gif