APNG Feature Detection


/ Published in: JavaScript
Save to your folder(s)

APNG Feature Detection
================
This code will set the variable, `apng_supported` to true if APNG and `` are supported.

This script requires the following APNG image (157 bytes): http://code.eligrey.com/apng-detect/apng-test.png


Copy this code and paste it in your HTML
  1. (function(_global) {
  2. var apng_test = new Image(),
  3. ctx = document.createElement("canvas").getContext("2d");
  4. apng_test.src = "apng-test.png"; // a data URI will cause a security error so you _have_ to link to an external resource
  5. // frame 1 (skipped on apng-supporting browsers): 0,0,0,255
  6. // frame 2: 0,0,0,0
  7. apng_test.onload = function() {
  8. ctx.drawImage(apng_test, 0, 0);
  9. _global.apng_supported = ( ctx.getImageData(0, 0, 1, 1).data[3] == 0 );
  10. }
  11. })(this);

URL: http://eligrey.com/2009/03/03/apng-feature-detection/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.