Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setImageCompression example
$quality_result
= parent::
set_quality
(
$quality
)
;
if
(
is_wp_error
(
$quality_result
)
)
{
return
$quality_result
;
}
else
{
$quality
=
$this
->
get_quality
(
)
;
}
try
{
switch
(
$this
->mime_type
)
{
case
'image/jpeg':
$this
->image->
setImageCompressionQuality
(
$quality
)
;
$this
->image->
setImageCompression
(
imagick::COMPRESSION_JPEG
)
;
break
;
case
'image/webp':
$webp_info
=
wp_get_webp_info
(
$this
->file
)
;
if
(
'lossless' ===
$webp_info
[
'type'
]
)
{
// Use WebP lossless settings.
$this
->image->
setImageCompressionQuality
(
100
)
;
$this
->image->
setOption
(
'webp:lossless', 'true'
)
;
}
else
{
$this
->image->
setImageCompressionQuality
(
$quality
)
;
}