public static function isTransparentPng($fileName)
    {
        $bytes = file_get_contents($fileName, false, null, 24, 2);    // read 24th and 25th bytes
        $byte24 = ord($bytes{0});
        $byte25 = ord($bytes{1});
        if ($byte24 === 16 || $byte25 === 6 || $byte25 === 4) {
            return true;
        } else {
            $content = file_get_contents($fileName);
            return strpos($content, 'tRNS') !== false;
        }
    }
public static function isTransparentPng($fileName)
    {
        $bytes = file_get_contents($fileName, false, null, 24, 2);    // read 24th and 25th bytes
        $byte24 = ord($bytes{0});
        $byte25 = ord($bytes{1});
        if ($byte24 === 16 || $byte25 === 6 || $byte25 === 4) {
            return true;
        } else {
            $content = file_get_contents($fileName);
            return strpos($content, 'tRNS') !== false;
        }
    }
Returns true if the given PNG file contains transparency information.

@param string $fileName
@return bool