0

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.

Dipayan
  • 1
  • 7
  • This isn't something you apply ta an image per say, but it is used before rendering the image on the front end. This goes where you're generating your image (eg: a post thumbnail). It's not possible to do it the way you want. – amarinediary Jul 02 '20 at 19:47
  • thank you for comment. if there's any other way to apply that effect, that will be okay. I just want to apply that effect permanently and automatically any how. – Dipayan Jul 02 '20 at 19:59
  • Does this answer your question? [WordPress - Blur Image on Upload](https://stackoverflow.com/questions/34377231/wordpress-blur-image-on-upload) – Robert Columbia Jul 04 '20 at 20:01
  • i don't know where and how to put codes. with modification... i need a elongated guide. please help – Dipayan Jul 05 '20 at 06:16
  • @RobertColumbia I am unaware of the file directory and process to add those code. that question has some resize issue which in my case isn't. I want to apply this filter to any picture uploaded. – Dipayan Jul 05 '20 at 06:28

0 Answers0