Multiple thumbnail sizes doesn't work

See all posts Reply

Multiple thumbnail sizes doesn't work new!
by Derek, 11 years, 9 months ago
We are trying to use the class to make multiple sized images of the original image. The first thumbnail size is generated fine, the medium size ends up being the same size as the original.

Also, the $medium_width and $medium_height that get returned are the same as the thumbnail

// Let's make some baby photos!
require_once(SUNSHINE_PATH.'/includes/class.upload.php');
$image = new Upload($upload_dir['basedir'].'/sunshine/'.$dir.'/'.$basename);
// Resize defaults
$image->image_resize = true;
$image->jpeg_quality = 100;
$image->auto_create_dir = true;
$image->dir_auto_chmod = true;
$image->image_ratio_y = true;
$image->file_overwrite = true;
// Make thumbnail
$image->image_x = 100;
$image->Process($upload_dir['basedir'].'/sunshine/'.$dir.'/thumbnail');
$thumb_result = $image->processed;
$thumb_width = $image->image_dst_x;
$thumb_height = $image->image_dst_y;
// Make medium
$image->image_x = 400;
$image->Process($upload_dir['basedir'].'/sunshine/'.$dir.'/medium');
$medium_result = $image->processed;
$medium_width = $image->image_dst_x;
$medium_height = $image->image_dst_y;
// If we were able to make thumbnail/medium, then let's add attachment to the database
if ($thumb_result && $medium_result) { 
  ...
} else {
  echo 'error : ' . $image->error;
}
Reply
Re: Multiple thumbnail sizes doesn't work new!
by Derek, 11 years, 9 months ago
Figured it out - we have to redeclare all the image_resize, jpeg_quality, etc after running process.Reply
Re: Multiple thumbnail sizes doesn't work new!
by Derek Ashauer, 11 years, 9 months ago
OK, so after further checking it appears it is not making the second thumbnail image - it simply duplicates the original.

How do you make two resized images from an original in one script?Reply
Re: Multiple thumbnail sizes doesn't work new!
by colin, 11 years, 9 months ago
Please check out the canonical code sample on the main page.Reply