Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author nosilver4u

    (@nosilver4u)

    Yeah, there’s no WP-CLI commands in Imsanity, but there are in my other plugin, the EWWW Image Optimizer, which has the same resizing options. I’ve never tried it for just resizing, but you could set the compression to lossless which will save you a little more space than just pure resizing.

    Thread Starter eduardoarandah

    (@eduardoarandah)

    Let me suggest a simple refactor like this:

    
    function imsanity_resize_image()
    {
    	imsanity_verify_permission();
    	global $wpdb;
    	$id = (int) $_POST['id'];
    
    	$results=imsanity_resize_image_id($id);
    	
    	die( json_encode( $results ) );
    }
    
    Plugin Author nosilver4u

    (@nosilver4u)

    I could, but to what end? So you can use the imsanity_resize_image_id() function via WP-CLI’s eval command? Then you still have to get a list of attachment IDs, write a script to run eval a bunch of times (or send one really long bit of PHP to the eval command).
    Why not just use EWWW IO’s WP-CLI command and be done with it?

    Thread Starter eduardoarandah

    (@eduardoarandah)

    You’re right!

    EWWW is perfect for the job.

    I’ll leave this code for anyone who needs it:

    # how to install required packages in ubuntu 16
    
    sudo apt-get update && sudo apt-get install -y libjpeg-progs imagemagick php-imagick graphicsmagick gifsicle
    
    # run wp command, if not installed, install it in https://wp-cli.org/
    
    wp ewwwio optimize media --skip-themes
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to bulk resize using command line’ is closed to new replies.