module.graphic.svg.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at http://getid3.sourceforge.net //
  5. // or http://www.getid3.org //
  6. /////////////////////////////////////////////////////////////////
  7. // See readme.txt for more details //
  8. /////////////////////////////////////////////////////////////////
  9. // //
  10. // module.graphic.svg.php //
  11. // module for analyzing SVG Image files //
  12. // dependencies: NONE //
  13. // author: Bryce Harrington <bryceØbryceharrington*org> //
  14. // ///
  15. /////////////////////////////////////////////////////////////////
  16. class getid3_svg
  17. {
  18. function getid3_svg(&$fd, &$ThisFileInfo) {
  19. fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
  20. // I'm making this up, please modify as appropriate
  21. $SVGheader = fread($fd, 32);
  22. $ThisFileInfo['svg']['magic'] = substr($SVGheader, 0, 4);
  23. if ($ThisFileInfo['svg']['magic'] == 'aBcD') {
  24. $ThisFileInfo['fileformat'] = 'svg';
  25. $ThisFileInfo['video']['dataformat'] = 'svg';
  26. $ThisFileInfo['video']['lossless'] = true;
  27. $ThisFileInfo['video']['bits_per_sample'] = 24;
  28. $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
  29. $ThisFileInfo['svg']['width'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
  30. $ThisFileInfo['svg']['height'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 4));
  31. $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['svg']['width'];
  32. $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['svg']['height'];
  33. return true;
  34. }
  35. $ThisFileInfo['error'][] = 'Did not find SVG magic bytes "aBcD" at '.$ThisFileInfo['avdataoffset'];
  36. unset($ThisFileInfo['fileformat']);
  37. return false;
  38. }
  39. }
  40. ?>