- $dimsByPage = array();
- $count = count( $tree->xpath( '//OBJECT' ) );
- for ( $i = 0; $i < $count; ++$i ) {
- $o = $tree->BODY[0]->OBJECT[$i];
- if ( $o ) {
- $dimsByPage[$i] = array(
- 'width' => (int)$o['width'],
- 'height' => (int)$o['height']
- );
- } else {
- $dimsByPage[$i] = false;
+ protected function getDimensionInfo( File $file ) {
+ $cache = ObjectCache::getMainWANInstance();
+ return $cache->getWithSetCallback(
+ $cache->makeKey( 'file-djvu', 'dimensions', $file->getSha1() ),
+ $cache::TTL_INDEFINITE,
+ function () use ( $file ) {
+ $tree = $this->getMetaTree( $file );
+ if ( !$tree ) {
+ return false;