Resize images in batch

Ankit
you can re-size images by using this script via terminal:

<?php

ini_set('max_execution_time', 0);
set_time_limit(0);

require_once('./wp-load.php');
require_once( './wp-admin/includes/admin.php' );

for($i=0;$i<=500;$i++){

$attachments =& get_children(array(
        'post_type' => 'attachment',
        'post_mime_type' => 'image',
        'numberposts' => 50,
        'paged' => $i,
        'post_status' => null,
        'post_parent' => null
    ), ARRAY_A);

foreach ( $attachments as $attachment ) {
    $image = get_post($attachment['ID']);
    $original_size_path = get_attached_file($image->ID);

    if (false === $original_size_path || !file_exists($original_size_path)) {
        echo 'File Not Found: ';
    } else {
        $metadata = wp_generate_attachment_metadata($image->ID, $original_size_path);

        if (is_wp_error($metadata) || empty($metadata))
            echo 'Unknown failure reason: '. $original_size_path;

        wp_update_attachment_metadata($image->ID, $metadata);
    }
}

echo 'Done page '. $i.' ====== ';
mail('[email protected]',('Page'.$i.'done'),('Page'.$i.'done'));
unset($attachments);
unset($image);
unset($original_size_path);
unset($metadata);
sleep(1);
}
mail('[email protected];','Done','Done Images Thumbnail Generation');
?>

You just need to change the value of $i in for loop and your email address.Save this file as “something.php” and run this in your terminal via ssh.
Hope this helps.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)