Resizing Images for a Gallery-Plugin?

Its best practice to always use internal WordPress API functions that already exist in place of external scripts.

You would need to regenerate the thumbnails yourself, which is not overly difficult, if for instance you give yourself a head start and study the source code of existing and similar solutions;

  1. Regenerate Thumbnails Plugin
  2. Simple Image Sizes

…which are two plugins designed to do just the very thing.

Also the following is an extract from this answer on the same subject which may also in turn be taken as sample from the Regenerate Thumbnail plugin as an example or be based upon it for example sake. Either way the same suggestion applies “see how others are doing it”

function regenerateThumbnails() {

    $images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type="attachment" AND post_mime_type LIKE 'image/%'" );

    foreach ( $images as $image ) {
        $id = $image->ID;
        $fullsizepath = get_attached_file( $id );

        if ( false === $fullsizepath || !file_exists($fullsizepath) )
            return;

        if ( wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $fullsizepath ) ) )
            return true;
        else
            return false;
    }
}

Sorich87 said…

Note: This function is not very scalable. It will loop through all the
images and regenerate thumbnails one by one, which may consume a large
amount of memory. So, you may want to enhance it.

…and I agree, but at least it plants the seed. Refer to the attachments section of the Function Reference in the Codex for a list of common image related functions, in particular (but not limited too),