our clients
Batch processing tutorial
In this example we will process many photos from directory and save information about them into the database.I assume in this tutorial that user images are stored in /users/USER_ID/ directory and thumbs are will be placed in /users/USER_ID/thumbs/
<?php
function callfunc(& $thumb)
{
global $user;
// catch errors
try
{
// square thumb for every image
// save it to the user's directory
$thumb->thumbSquare(100)->save('/users/'.$user->id.'/thumbs/'.$thumb->filename;
// save information to the database
$sql=mysql_real_escape_string('insert into `user_photos` (`photo`) values ("'.$thumb->filename.'")');
mysql_query($sql);
// done
return true;
}
catch (Exception $e)
{
// if error occured
return 'Error occured for '.$thumb->filename.' - '.$e->getMessage();
}
}
// run Thumbnailer in batch mode
// make thumb for every jpg, gif and png image
$results=Thumbnailer::batch('callfunc', '/users/'.$user->id.'/*.{jpg,gif,png}');
// check for errors
foreach($results as $result)
{
if ($result !== true)
{
echo $result.'<br />';
}
}
?>
Tutorials
-
How to install Wordpress 3
09/04/2011Installing Wordpress is easy and fun
-
Installing MySQL Windows
09/03/2011We will teach you how to install MySQL and get it working in PHP in this step by step tutorial.
-
Installing PHP 5.3 with Apache on Windows
09/03/2011We will teach you how to install PHP as an Apache module in this step by step tutorial.
-
How to install Apache on Windows
09/03/2011We will teach you how to setup Apache environment on Windows in this step by step tutorial.
-
Understanding paths in PHP
03/05/2011Ever wondered how to properly include files? Here's your chance
-
Batch processing tutorial
03/01/2011In this example we will process many photos from directory and save information about them into the database.
-
Create a thumb from uploaded image
04/02/2010Check out how to quickly create a thumb from uploaded image.