image_thumbnail_client.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. *
  8. * Use and distribution licensed under the PHP license. See
  9. * the LICENSE file in this directory for full text.
  10. */
  11. /* create our object */
  12. $gmc= new GearmanClient();
  13. /* add the default server */
  14. $gmc->addServer();
  15. $data['src']= $_SERVER['argv'][1];
  16. $data['dest']= "small_" . $_SERVER['argv'][1];
  17. $data['x']= 200;
  18. $data['y']= NULL;
  19. /* run reverse client */
  20. do
  21. {
  22. $value = $gmc->do("shrink_image", serialize($data));
  23. switch ($gmc->returnCode())
  24. {
  25. case GEARMAN_WORK_DATA:
  26. echo "DATA: $value\n";
  27. break;
  28. case GEARMAN_SUCCESS:
  29. echo "SUCCESS: $value\n";
  30. break;
  31. case GEARMAN_WORK_STATUS:
  32. list($numerator, $denominator)= $gmc->doStatus();
  33. echo "Status: $numerator/$denominator\n";
  34. break;
  35. default:
  36. echo "ERR: " . $gmc->error() . "\n";
  37. }
  38. }
  39. while($gmc->returnCode() != GEARMAN_SUCCESS);
  40. echo "DONE: $value\n";