function is_webp($hdr) { return substr($hdr, 0, 4) == 'RIFF' && substr($hdr, 8, 4) == 'WEBP'; } // Getting width and height of WEBP image PHP's GD lib. Works even in PHP lower than v5.5. function get_webp_size($fn) { $w = 0; $h = 0; if ($f = @fopen($fn, 'rb')) { $hdr = fread($f, 32); fclose($f); if (strlen($hdr) >= 30) { $w = unpack('C3b', substr($hdr, 24, 3)); $w = ($w['b1'] + $w['b2']*256 + $w['b3']*65536) + 1; $h = unpack('C3b', substr($hdr, 27, 3)); $h = ($h['b1'] + $h['b2']*256 + $h['b3']*65536) + 1; } } return array($w, $h); } ———————————— This document has been copied from FAVOR.com.ua (https://favor.com.ua/en/blogs/30962.html). All rights reserved by author of the material. In case of re-publication, the link to the source of the material is strongly required! Document date: March 3, 2019