class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
I have similar problem. I have few pictures in a local folder and i want in a loop resize each of them and save to diferent folder.
I read all files in the array and make loop foreach. Script goes well if there are small pictures and not a lot. If in folder are big pictures and many pictures the time limit for the script execution is the problem.
Any idea for resolving this problem? Aby script exaple?
exemple:
I have 37 pic in the folder, but the class just resize and crop 27 or less
it's my code, take a look!
thk!!
$dir = "../images/albums/"; $album = $_POST['album']; $add = $_POST['add']; $b_dir = $dir.$album."/"; $aid = $_POST['aid']; $thumb_path = "../images/albums/$album/thumb/"; if($add == 1){ if (is_dir($b_dir)) { if ($dh = opendir($b_dir)) { $i = 1; while (($file = readdir($dh)) !== false) { $tes = explode(".", $file); $arr_tmp = explode(".",$file); $formato = array_pop($arr_tmp); if( "." == $file || ".." == $file){ continue; } elseif($tes[1] == "db") { continue; } $full_path = "../images/albums/$album/full/"; $normal_path = "../images/albums/$album/normal/"; $thumb_path = "../images/albums/$album/thumb/"; $file_pacth = "../images/albums/".$album."/".$file; // Instanciamos o objeto Upload $handle = new Upload($file_pacth); $handle->auto_create_dir = true; $handle->file_overwrite = true; $handle->file_auto_rename = false; $stamp_name = time(); // Definimos as configurações desejadas da imagem normal $handle->image_resize = true; $handle->image_ratio_y = false; $handle->image_x = 460; $handle->image_y = 320; $handle->image_watermark = '../images/watermark.png'; $handle->image_watermark_x = -10; $handle->image_watermark_y = -10; $handle->file_new_name_body = "$stamp_name"; $handle->file_name_body_add = '_normal'; $handle->image_ratio_crop = true; // Definimos a pasta para onde a imagem maior será armazenada $handle->Process($normal_path); $nome_da_imagem_normal = $handle->file_dst_name; $normal = $normal_path.$nome_da_imagem_normal; // Aqui nos devifimos nossas configurações de imagem do thumbs $handle->image_resize = true; $handle->image_ratio_y = false; $handle->image_x = 100; $handle->image_y = 75; $handle->image_contrast = 10; $handle->jpeg_quality = 100; $handle->file_new_name_body = "$stamp_name"; $handle->file_name_body_add = '_thumb'; $handle->image_ratio_crop = true; // Definimos a pasta para onde a imagem thumbs será armazenada $handle->Process($thumb_path); $nome_da_imagem_thumb = $handle->file_dst_name; $thumb = $thumb_path.$nome_da_imagem_thumb; $i++; } closedir($dh); if ($handle->processed) { //$adiciona = "INSERT INTO csm_galeria_fotos (fid,aid,titulo,descricao,thumb,img,full) VALUES('','".$aid."','".$titulo."','".$desc."','".$thumb."','".$normal."','".$full."')"; //mysql_query($adiciona) or die("Não Foi Possível Adicionar A Imagem!"); echo 'Operação realizada com sucesso!'; echo "$i".$file_pacth.""; } else { // Em caso de erro listamos o erro abaixo echo 'Erro encontrado!'; echo 'Erro: ' . $handle->error . ''; } } } }You are probably running out of memory. Try to increase the memory for PHP, or else process your images in batches.
if I have 100 pics in the folder, the class just crop and resize 50 or less
I using the verssion 0.24, I try use the 0.25
I already increase the memory, but doesn't work!
I will record a video of my problem and post here
see ya!
I read all files in the array and make loop foreach. Script goes well if there are small pictures and not a lot. If in folder are big pictures and many pictures the time limit for the script execution is the problem.
Any idea for resolving this problem? Aby script exaple?
Thanks a lot. and sorry for my english :)