X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FExifBitmap.php;h=0e10abb9f9329ee7c8942e3c9826c3155b2231a4;hb=c9be16a35596ff369bb5f700c20ae8dc2f7def48;hp=7aeefa02e4320d82ae8fd41e6938b47b2f3ff5a6;hpb=adae996840b9e782f6e14b21c433a83e37c3a74e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/ExifBitmap.php b/includes/media/ExifBitmap.php index 7aeefa02e4..0e10abb9f9 100644 --- a/includes/media/ExifBitmap.php +++ b/includes/media/ExifBitmap.php @@ -30,7 +30,6 @@ class ExifBitmapHandler extends BitmapHandler { const BROKEN_FILE = '-1'; // error extracting metadata const OLD_BROKEN_FILE = '0'; // outdated error extracting metadata. - const SRGB_ICC_PROFILE_NAME = 'IEC 61966-2.1 Default RGB colour space - sRGB'; function convertMetadataVersion( $metadata, $version = 1 ) { // basically flattens arrays. @@ -243,75 +242,4 @@ class ExifBitmapHandler extends BitmapHandler { return 0; } - - protected function transformImageMagick( $image, $params ) { - global $wgUseTinyRGBForJPGThumbnails; - - $ret = parent::transformImageMagick( $image, $params ); - - if ( $ret ) { - return $ret; - } - - if ( $params['mimeType'] === 'image/jpeg' && $wgUseTinyRGBForJPGThumbnails ) { - // T100976 If the profile embedded in the JPG is sRGB, swap it for the smaller - // (and free) TinyRGB - - $this->swapICCProfile( - $params['dstPath'], - self::SRGB_ICC_PROFILE_NAME, - realpath( __DIR__ ) . '/tinyrgb.icc' - ); - } - - return false; - } - - /** - * Swaps an embedded ICC profile for another, if found. - * Depends on exiftool, no-op if not installed. - * @param string $filepath File to be manipulated (will be overwritten) - * @param string $oldProfileString Exact name of color profile to look for - * (the one that will be replaced) - * @param string $profileFilepath ICC profile file to apply to the file - * @since 1.26 - * @return bool - */ - public function swapICCProfile( $filepath, $oldProfileString, $profileFilepath ) { - global $wgExiftool; - - if ( !$wgExiftool || !is_executable( $wgExiftool ) ) { - return false; - } - - $cmd = wfEscapeShellArg( $wgExiftool, - '-DeviceModelDesc', - '-S', - '-T', - $filepath - ); - - $output = wfShellExecWithStderr( $cmd, $retval ); - - if ( $retval !== 0 || strcasecmp( trim( $output ), $oldProfileString ) !== 0 ) { - // We can't establish that this file has the expected ICC profile, don't process it - return false; - } - - $cmd = wfEscapeShellArg( $wgExiftool, - '-overwrite_original', - '-icc_profile<=' . $profileFilepath, - $filepath - ); - - $output = wfShellExecWithStderr( $cmd, $retval ); - - if ( $retval !== 0 ) { - $this->logErrorForExternalProcess( $retval, $output, $cmd ); - - return false; - } - - return true; - } }