image_thumbnail_client_bg.php 838 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * Gearman PHP Extension
  4. *
  5. * Copyright (C) 2008 James M. Luedke (jluedke@jamesluedke.com)
  6. * Eric Day (eday@oddments.org)
  7. * All rights reserved.
  8. *
  9. * Use and distribution licensed under the PHP license. See
  10. * the LICENSE file in this directory for full text.
  11. */
  12. /* create our object */
  13. $gmc= new GearmanClient();
  14. /* add the default server */
  15. $gmc->addServer();
  16. for ($x=0; $x<20; $x++)
  17. {
  18. $data[$x]['src']= $_SERVER['argv'][1];
  19. $data[$x]['dest']= "$x.jpg";
  20. $data[$x]['x']= ((80+1)*($x+1));
  21. $data[$x]['y']= NULL;
  22. }
  23. /* fire off each job */
  24. foreach ($data as $img)
  25. {
  26. $job_handle[]= $gmc->doBackground("shrink_image", serialize($img));
  27. if ($gmc->returnCode() != GEARMAN_SUCCESS)
  28. {
  29. echo "ERROR RET: " . $gmc->error() . "\n";
  30. exit;
  31. }
  32. }
  33. echo "DONE\n";