/** * @covers BitmapHandler::getImageArea */ public function testImageArea() { $file = new FakeDimensionFile(array(7, 9)); $handler = new BitmapHandler(); $this->assertEquals(63, $handler->getImageArea($file)); }
/** * Check the file and params against $wgVipsOptions * * @param BitmapHandler $handler * @param File $file * @param array $params * @return bool */ protected static function getHandlerOptions( $handler, $file, $params ) { global $wgVipsOptions; # Iterate over conditions foreach ( $wgVipsOptions as $option ) { if ( isset( $option['conditions'] ) ) { $condition = $option['conditions']; } else { # Unconditionally pass return $option; } if ( isset( $condition['mimeType'] ) && $file->getMimeType() != $condition['mimeType'] ) { continue; } $area = $handler->getImageArea( $file ); if ( isset( $condition['minArea'] ) && $area < $condition['minArea'] ) { continue; } if ( isset( $condition['maxArea'] ) && $area >= $condition['maxArea'] ) { continue; } $shrinkFactor = $file->getWidth() / ( ( ( $handler->getRotation( $file ) % 180 ) == 90 ) ? $params['physicalHeight'] : $params['physicalWidth'] ); if ( isset( $condition['minShrinkFactor'] ) && $shrinkFactor < $condition['minShrinkFactor'] ) { continue; } if ( isset( $condition['maxShrinkFactor'] ) && $shrinkFactor >= $condition['maxShrinkFactor'] ) { continue; } # This condition passed return $option; } # All conditions failed return false; }