Created
January 28, 2010 16:35
-
-
Save pifantastic/288895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get uncompressed size of file | |
$fp = fopen($filename, 'rb'); | |
fseek($fp, -4, SEEK_END); | |
$buf = fread($fp, 4); | |
$size = end(unpack('V', $buf)); | |
fclose($fp); | |
// Get uncompressed contents of file | |
$zd = gzopen($filename, 'rb'); | |
$contents = gzread($zd, $size); | |
gzclose($zd); | |
// Write svg file | |
$svg = pathinfo($filename, PATHINFO_FILENAME).'.svg'; | |
$fp = fopen($svg, 'wb'); | |
fwrite($fp, $contents); | |
fclose($fp); | |
// Read svg meta | |
$svgxml = simplexml_load_string($contents); | |
// Extract width and height | |
$width = (string) $svgxml['width']; | |
$height = (string) $svgxml['height']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment