WebP image format support
WebP image format is available from
- Chrome 23
- Opera 12.1
- Opera Mini
- Android Brower 4.3
- Opera Mobile
- Chrome for Android
- Partial support in older Chrome, Opera and Android, not supporting lossless and alpha versions of WebP.
WebP support detection is simple, check Accept Header for image/webp.
1 |
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 |
1 2 3 4 |
if ((isset($_SERVER['HTTP_ACCEPT']) === true) && (strstr($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false)) { # Do something for WebP users $picture->setImageFormat('webp'); } |
JP2 image format support
JPEG-2000 or JP2 is available from
- Safari 5 (Not in the Windows version)
- iOS Safari 5.1
Because Safari 5 only represents 0.22% of browser usage on the world, we are going to ignore the Windows/Mac detection and start from version 6.
Safari Accept Header does not specify JP2 support, so as a fallback we are going to check if the browser is Safari, and check it’s version.
1 |
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 |
1 2 3 4 5 6 |
if ((isset($_SERVER['HTTP_USER_AGENT']) === true) && (strstr($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false)) { if ((preg_match('/Version\/(?P<version>[0-9]{1})/', $_SERVER['HTTP_USER_AGENT'], $parameters)) && ($parameters['version'] >= 6)) { # Do something for JP2 support $picture->setImageFormat('jp2'); } } |
JXR image format support
JPEG XR format is available from
- IE 8
- Edge 12
JPEG XR support detection is simple, check Accept Header for image/webp.
1 2 3 4 |
if ((isset($_SERVER['HTTP_ACCEPT']) === true) && (strstr($_SERVER['HTTP_ACCEPT'], 'image/jxr') !== false)) { # Do something for JPEG XR users $picture->setImageFormat('jxr'); } |
This image format compression is great without too much quality downgrade, but converting images to JXR in command line is buggy with ImageMagick, and difficult with libjxr-tools.
Future image format support
For future browser release, check caniuse.com website, it provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.