Parameters
- $quality
-
(int) (Optional) Compression Quality. Range: [1,100]
Default value: null
Source
File: wp-includes/class-wp-image-editor-imagick.php
public function set_quality( $quality = null ) {
$quality_result = parent::set_quality( $quality );
if ( is_wp_error( $quality_result ) ) {
return $quality_result;
} else {
$quality = $this->get_quality();
}
try {
if ( 'image/jpeg' === $this->mime_type ) {
$this->image->setImageCompressionQuality( $quality );
$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
} else {
$this->image->setImageCompressionQuality( $quality );
}
} catch ( Exception $e ) {
return new WP_Error( 'image_quality_error', $e->getMessage() );
}
return true;
}
Changelog
Version | Description |
3.5.0 | Introduced. |