/** * @covers ExifBitmapHandler::convertMetadataVersion */ public function testConvertMetadataSoftwareNormal() { $metadata = array('Software' => array("GIMP 1.2", "vim"), 'MEDIAWIKI_EXIF_VERSION' => 2); $expected = array('Software' => "\n*GIMP 1.2\n*vim", 'MEDIAWIKI_EXIF_VERSION' => 1); $res = $this->handler->convertMetadataVersion($metadata, 1); $this->assertEquals($expected, $res); }
/** * @dataProvider provideSwappingICCProfile * @covers BitmapHandler::swapICCProfile */ public function testSwappingICCProfile($sourceFilename, $controlFilename, $newProfileFilename, $oldProfileName) { global $wgExiftool; if (!$wgExiftool || !is_file($wgExiftool)) { $this->markTestSkipped("Exiftool not installed, cannot test ICC profile swapping"); } $this->setMwGlobals('wgUseTinyRGBForJPGThumbnails', true); $sourceFilepath = $this->filePath . $sourceFilename; $controlFilepath = $this->filePath . $controlFilename; $profileFilepath = $this->filePath . $newProfileFilename; $filepath = $this->getNewTempFile(); copy($sourceFilepath, $filepath); $file = $this->dataFile($sourceFilename, 'image/jpeg'); $this->handler->swapICCProfile($filepath, $oldProfileName, $profileFilepath); $this->assertEquals(sha1(file_get_contents($filepath)), sha1(file_get_contents($controlFilepath))); }
/** * @param $file File * @param array $params Rotate parameters. * 'rotation' clockwise rotation in degrees, allowed are multiples of 90 * @since 1.21 * @return bool */ public function rotate($file, $params) { global $wgJpegTran; $rotation = ($params['rotation'] + $this->getRotation($file)) % 360; if ($wgJpegTran && is_file($wgJpegTran)) { $cmd = wfEscapeShellArg($wgJpegTran) . " -rotate " . wfEscapeShellArg($rotation) . " -outfile " . wfEscapeShellArg($params['dstPath']) . " " . wfEscapeShellArg($params['srcPath']) . " 2>&1"; wfDebug(__METHOD__ . ": running jpgtran: {$cmd}\n"); wfProfileIn('jpegtran'); $retval = 0; $err = wfShellExec($cmd, $retval, $env); wfProfileOut('jpegtran'); if ($retval !== 0) { $this->logErrorForExternalProcess($retval, $err, $cmd); return new MediaTransformError('thumbnail_error', 0, 0, $err); } return false; } else { return parent::rotate($file, $params); } }
public function sanitizeParamsForBucketing($params) { $params = parent::sanitizeParamsForBucketing($params); // Quality needs to be cleared for bucketing. Buckets need to be default quality if (isset($params['quality'])) { unset($params['quality']); } return $params; }