Last active
March 23, 2023 23:48
-
-
Save nosilver4u/759ee819f7e3def844c4b54a74a3c44a to your computer and use it in GitHub Desktop.
EWWW IO adjust Sharpening functions/params.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: EWWW IO Adjust Sharpening | |
Version: 1.0.0 | |
*/ | |
/* | |
* Valid options: | |
* 'FILTER_POINT', | |
* 'FILTER_BOX', | |
* 'FILTER_TRIANGLE', | |
* 'FILTER_HERMITE', | |
* 'FILTER_HANNING', | |
* 'FILTER_HAMMING', | |
* 'FILTER_BLACKMAN', | |
* 'FILTER_GAUSSIAN', | |
* 'FILTER_QUADRATIC', | |
* 'FILTER_CUBIC', | |
* 'FILTER_CATROM', | |
* 'FILTER_MITCHELL', | |
* 'FILTER_LANCZOS', | |
* 'FILTER_BESSEL', | |
* 'FILTER_SINC' | |
*/ | |
add_filter( 'eio_image_resize_filter', 'eio_change_image_resize_filter', 10, 3 ); | |
function eio_change_image_resize_filter( $filter_name, $dst_w, $dst_h ) { | |
return 'FILTER_TRIANGLE'; | |
} | |
// Change false to true to enable the use of the adaptiveSharpenImage() function. | |
add_filter( 'eio_use_adaptive_sharpen', 'eio_enable_adaptive_sharpen', 10, 3 ); | |
function eio_enable_adaptive_sharpen( $use_adaptive, $dst_w, $dst_h ) { | |
return false; | |
} | |
// Here's an example of using the extra width and height params. | |
add_filter( 'eio_adaptive_sharpen_radius', 'eio_adjust_adaptive_sharpen_radius', 10, 3 ); | |
function eio_adjust_adaptive_sharpen_radius( $param, $dst_w, $dst_h ) { | |
if ( $dst_w > 2000 || $dst_h > 2000 ) { | |
return 0; | |
} | |
return 0; | |
} | |
add_filter( 'eio_adaptive_sharpen_sigma', 'eio_adjust_adaptive_sharpen_sigma', 10, 3 ); | |
function eio_adjust_adaptive_sharpen_sigma( $param, $dst_w, $dst_h ) { | |
return 1; | |
} | |
add_filter( 'eio_sharpen_radius', 'eio_adjust_sharpen_radius', 10, 3 ); | |
function eio_adjust_sharpen_radius( $param, $dst_w, $dst_h ) { | |
return 0.25; | |
} | |
add_filter( 'eio_sharpen_sigma', 'eio_adjust_sharpen_sigma', 10, 3 ); | |
function eio_adjust_sharpen_sigma( $param, $dst_w, $dst_h ) { | |
return 0.25; | |
} | |
add_filter( 'eio_sharpen_amount', 'eio_adjust_sharpen_amount', 10, 3 ); | |
function eio_adjust_sharpen_amount( $param, $dst_w, $dst_h ) { | |
return 8; | |
} | |
add_filter( 'eio_sharpen_threshold', 'eio_adjust_sharpen_threshold', 10, 3 ); | |
function eio_adjust_sharpen_threshold( $param, $dst_w, $dst_h ) { | |
return 0.065; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment