PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/library/UrlTube/Thumb.php

https://bitbucket.org/baruffaldi/webapp-urltube
PHP | 71 lines | 57 code | 13 blank | 1 comment | 11 complexity | 894b1583c34c023a98a42d4aef982fbe MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. class UrlTube_Thumb
  3. {
  4. public $srcWidth = 0;
  5. public $srcHeight = 0;
  6. public $destWidth = 0;
  7. public $destHeight = 0;
  8. public function getThumbPath( $type, $url )
  9. {
  10. }
  11. public function getThumb( $type, $url )
  12. {
  13. global $_SITE;
  14. if ( ! empty( $url['url'] ) )
  15. switch ( $type )
  16. {
  17. default:
  18. if ( defined( '__DEBUG__' ) && __DEBUG__ ) var_dump( 'SCAN ENDED WITH FATAL ERROR, NO TYPE SPECIFIED' );
  19. return -2;
  20. break;
  21. case 'image':
  22. $thumbPath = $_SITE['config']['fs']['path_public'] . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . md5( $url['id_url'] ) . '.jpg';
  23. //var_dump( $thumbPath );
  24. if ( $url['image'] == 'N' || ! file_exists( $thumbPath ) )
  25. {
  26. if ( __DEBUG__ )
  27. var_dump( 'CReATING THUMB' );
  28. $t1 = new ImageBatchTransformation();
  29. $t1->source = $url['url'];
  30. $t1->destination = $thumbPath;
  31. $t1->maxWidth = 250;
  32. $t1->maxHeight = 200;
  33. $t1->format = TI_JPEG;
  34. $t1->jpegQuality = 95;
  35. $t1->interlace = true;
  36. $t1->replaceExisted = false;
  37. $t1->label['text'] = date('y') . ' (c) ' . $_SITE['config']['handler']->redirect->domain;
  38. $t1->label['vertPos'] = TI_POS_BOTTOM;
  39. $t1->label['horzPos'] = TI_POS_RIGHT;
  40. $t1->label['font'] = $_SITE['config']['fs']['path_public'] . DIRECTORY_SEPARATOR . 'FREESCPT.TTF';
  41. $t1->label['size'] = 10;
  42. $t1->label['color'] = '#ffff00';
  43. $t1->label['angle'] = 0;
  44. $t1->label['rotateAngle'] = 0;
  45. $t1->label['rotateBgColor'] = '#ffffff';
  46. $ibp = new ImageBatchProcessor();
  47. $n = $ibp->processEx(array($t1));
  48. $this->srcHeight = $imageHeight;
  49. $this->srcWidth = $imageWidth;
  50. if ( __DEBUG__ )
  51. var_dump("FINISHED");
  52. } else return FALSE;
  53. return TRUE;
  54. break;
  55. }
  56. else return FALSE;
  57. }
  58. }