This is from a CodeIgniter application that uses its image manipulation library.
$photos
contains an array of relative photo paths. This script should resize the original and also create a medium (_m) and small (_s) size.
When I only send one photo to the script, everything works great.
When I send a second, things get screwed up - the first image works fine, but then:
-The original second image isn't resized at all (should be resized to 800 wide/high)
-The "original" second image size (800x800) is named as a small image with the first image's file name.
foreach($photos as $photo) {
$config['image_library'] = 'gd2';
$config['source_image'] = $photo;
$config['maintain_ratio'] = TRUE;
$photoparts = pathinfo($photo);
// Resize Original
$config['width'] = 800;
$config['height'] = 800;
$this->image_lib->initialize($config);
$this->image_lib->resize();
// Medium Size
$config['width'] = 500;
$config['height'] = 500;
$config['new_image'] = $photoparts['dirname'].'/'.$photoparts['filename'].'_m.'.$photoparts['extension'];
$this->image_lib->initialize($config);
$this->image_lib->resize();
// Small Size
$config['width'] = 200;
$config['height'] = 200;
$config['new_image'] = $photoparts['dirname'].'/'.$photoparts['filename'].'_s.'.$photoparts['extension'];
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
I can't figure out for the life of me why the file names are getting mixed up. The only thing I can think of is that I'm doing this all on a local server, so maybe it's running so fast that the script gets ahead of itself? I doubt that's the case, though.