getImageProfiles( 'icc', true ); } catch ( ImagickException $e ) { $profiles = []; } if ( ! empty( $profiles ) ) { // Source has an ICC profile — leave it alone. This is the // common case for camera JPEGs and properly-saved Photoshop exports. return [ 'result' => true, 'source' => 'original' ]; } // No profile. Try to inject sRGB v4 fallback. $profile_path = self::srgb_profile_path(); if ( ! is_readable( $profile_path ) ) { return [ 'result' => false, 'source' => 'none' ]; } try { $img->setImageColorspace( Imagick::COLORSPACE_SRGB ); $img->profileImage( 'icc', (string) file_get_contents( $profile_path ) ); return [ 'result' => true, 'source' => 'injected' ]; } catch ( ImagickException $e ) { return [ 'result' => false, 'source' => 'none' ]; } } }