wrote a php script to resize images when a user uploads them. after testing it out a lot, it only seems to resize some of the images, not all. and I need ALL the images to be sized when the user uploads...
For example, if I upload a 1384x900px, 600kb file called "band_photo.jpg". It resizes correctly. But if I upload a 540x360px, 60kb file called "C&C group 17.jpg". It is not resized at all.
Here is the script. If someone could tell me how to change it so all the images are resized, I'd appreciate it:
$file_dir = "C:/sokkit/site/testim";
foreach($_FILES as $file_name => $file_array) {
if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'], "$file_dir/" . preg_replace('/[^a-z0-9_\-\.]/i', '_', strtolower($file_array['name']))) or die ("Couldn't copy");
// RESIZE IMAGE USING IMAGEMAGICK
function resize_constrained($path_convert,$file_path,$file_max_width) {
exec($path_convert ." -type TrueColor -geometry ". $file_max_width ." ". $file_path ." ". $file_path);
return;
}
define("PATH_CONVERT","C:/sokkit/Apache2/lib/ImageMagick-5.5.7-Q16/convert.exe");
$file_path = "$file_dir/$file_array[name]";
$file_max_width = 300;
resize_constrained(PATH_CONVERT,$file_path,$file_max_width);
// CROP IMAGE USING IMAGEMAGIC
}
}