问题
I don't really know how to apply php code to WordPress manually. I have found some script but don't know where and how to put them.
public Imagick::selectiveBlurImage ( float $radius , float $sigma , float $threshold [, int $channel = Imagick::CHANNEL_DEFAULT ] ) : bool
<?php
function selectiveBlurImage($imagePath, $radius, $sigma, $threshold, $channel) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->selectiveBlurImage($radius, $sigma, $threshold, $channel);
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
}
?>
Source Imagick::selectiveBlurImage
And want to add it as this filter will act before finally uploading image. Found similar function at wp-admin/includes/file.php
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
function custom_upload_filter( $file ){
$file['name'] = 'wordpress-is-awesome-' . $file['name'];
return $file;
}
Source 1st Page & 2nd Page
If there isn't any way to pre-apply filter effect then auto-apply effect after upload is welcome.
If there there is any WordPress Plug-in available to do that?
The effect will change original photo to this photo
Effect Source Fred's ImageMagick Scripts with effect arguments:
-b 4 -t 10 -e none -q 0
There is a similar question ,but i am unaware of the file directory and process to add those code. It has some resize issue which in my case isn't. I want to apply this filter to any picture uploaded.
来源:https://stackoverflow.com/questions/62703469/how-to-apply-imagemagick-effect-selective-blur-to-all-wordpress-uploaded-image