() ) ) { throw new ImagickNotSupportWebpException(); } $image->setImageFormat( $extension ); if ( ! in_array( ExtraFeaturesOption::OPTION_VALUE_KEEP_METADATA, $plugin_settings[ ExtraFeaturesOption::OPTION_NAME ] ) ) { $image_profiles = $image->getImageProfiles( '*', true ); foreach ( $image_profiles as $profile_name => $image_profile ) { if ( ! in_array( $profile_name, self::PROTECTED_IMAGE_PROFILES ) ) { try { $image->removeImageProfile( $profile_name ); } catch ( \ImagickException $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } } } } $image->setImageCompressionQuality( $output_quality ); $blob = $image->getImageBlob(); if ( ! file_put_contents( $output_path, $blob ) ) { throw new ConversionErrorException( $source_path ); } } }