Esempio n. 1
0
 /**
  * Test the size detection for PDF files.
  */
 function testSizePDF()
 {
     $info = binarypool_mime::getImageSize(realpath(dirname(__FILE__) . '/../res/emil_frey_logo_2.pdf'));
     $this->assertEqual($info['width'], '203');
     $this->assertEqual($info['height'], '40');
     $this->assertEqual($info['unit'], 'mm');
 }
Esempio n. 2
0
 /**
  * Returns the XML representation of a single item.
  *
  * @param $file: Absolute file name on the disk for this item.
  * @param $rendition: Rendition name. null if this is the original.
  */
 private function getItem($file, $rendition)
 {
     $fproxy = new binarypool_fileobject($file);
     if (!$fproxy->exists()) {
         throw new binarypool_exception(102, 404, "Referenced file in asset does not exist: {$file}");
     }
     $fileinfo = binarypool_fileinfo::getFileinfo($file);
     $mime = $fileinfo['mime'];
     $size = $fileinfo['size'];
     $hash = $fileinfo['hash'];
     $type = is_null($this->type) ? binarypool_render::getType($mime) : $this->type;
     $info = binarypool_mime::getImageSize($file, $mime, $type);
     $isRendition = is_null($rendition) ? 'false' : 'true';
     $isLandscape = $info['width'] > $info['height'] ? 'true' : 'false';
     $xml = '<item type="' . $type . '" isRendition="' . $isRendition . '">';
     $xml .= '<webobject isVisual="true" isAudioOnly="false" unit="' . htmlspecialchars($info['unit']) . '">';
     $xml .= '<objectWidth>' . $info['width'] . '</objectWidth>';
     $xml .= '<objectHeight>' . $info['height'] . '</objectHeight>';
     $xml .= '</webobject>';
     $xml .= '<imageinfo isLandscape="' . $isLandscape . '" unit="' . htmlspecialchars($info['unit']) . '">';
     $xml .= '<width>' . $info['width'] . '</width>';
     $xml .= '<height>' . $info['height'] . '</height>';
     $xml .= '</imageinfo>';
     if ($isRendition) {
         $xml .= '<rendition>' . htmlspecialchars($rendition) . '</rendition>';
     }
     if ($this->locationAbsolute) {
         $xml .= '<location absolute="true">' . $file . '</location>';
     } else {
         $xml .= '<location>' . htmlspecialchars($this->basepath . basename($file)) . '</location>';
     }
     $xml .= '<importsource />';
     $xml .= '<mimetype>' . htmlspecialchars($mime) . '</mimetype>';
     $xml .= '<size>' . $size . '</size>';
     $xml .= '<hash>' . htmlspecialchars($hash) . '</hash>';
     $xml .= '</item>';
     return $xml;
 }