PHP thumbnail generation class (supports imagemagick and gd libraries)

WBOY
Release: 2016-07-25 08:55:26
Original
808 people have browsed it
  1. /** Thumbnail generation class, supports imagemagick and gd library processing

  2. * Date: 2013-07-15
  3. * Author: fdipzone
  4. * Ver: 1.2
  5. * edit: bbs.it-home.org
  6. * Func:
  7. * public set_config: Set parameters
  8. * public create_thumb: Generate thumbnail image
  9. * private fit: Thumbnail image
  10. * private crop: Crop image
  11. * private gd_fit: GD library thumbnail image
  12. * private gd_crop: GD library crop image
  13. * private get_size: get the size to be converted
  14. * private get_crop_offset: get the offset of the crop
  15. * private add_watermark: add watermark
  16. * private check_handler: judgment processing Whether the program has been installed
  17. * private create_dirs: Create a directory
  18. * private exists: Determine whether the parameter exists
  19. * private to_log: Record the log
  20. * private hex2rgb: Convert hex color to rgb color
  21. * private get_file_ext: Get the image type
  22. *
  23. * ver : 1.1 Added GD library processing
  24. * ver: 1.2 Added width and height error parameter processing
  25. * Added conversion to RGB processing when the image colorspace is not RGB
  26. * Fixed the problem of transparent invalid area when using crop to save as gif, use +repage parameters, just delete the transparent invalid area
  27. *
  28. * tips: It is recommended to use imagemagick
  29. * The GD library does not support transparency watermarks. If you must use transparent watermarks, please make the watermark image transparent.
  30. * If the GD library outputs a gif with a transparent watermark, there will be problems.
  31. */
  32. class PicThumb{ // class start
  33. private $_log = null; // log file
  34. private $_handler = null; // Program for image processing, imagemagick/gd library
  35. private $_type = 'fit '; // fit or crop
  36. private $_source = null; // Original image path
  37. private $_dest = null; // Thumbnail path
  38. private $_watermark = null; // Watermark image
  39. private $_opacity = 75; / / Watermark image transparency, gd library does not support
  40. private $_gravity = 'SouthEast'; // Watermark placement location NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast
  41. private $_geometry = '+10+ 10'; // Watermark positioning, gd library does not support
  42. private $_croppos = 'TL'; // Screenshot location TL TM TR ML MM MR BL BM BR
  43. private $_bgcolor = null; // Filled background color
  44. private $_quality = 90; // Generated image quality
  45. private $_width = null; // Specify area width
  46. private $_height = null; // Specify area height
  47. // Initialization
  48. public function __construct($logfile=' '){
  49. if($logfile!=''){
  50. $this->_log = $logfile;
  51. }
  52. }
  53. // Set parameters
  54. public function set_config($param=array()){
  55. $this->_handler = $this->exists($param, 'handler')? strtolower($param['handler']) : null;
  56. $this->_type = $this->exists( $param, 'type')? strtolower($param['type']) : 'fit';
  57. $this->_watermark = $this->exists($param, 'watermark')? $param[' watermark'] : null;
  58. $this->_opacity = $this->exists($param, 'opacity')? $param['opacity'] : 75;
  59. $this->_gravity = $this- >exists($param, 'gravity')? $param['gravity'] : 'SouthEast';
  60. $this->_geometry = $this->exists($param, 'geometry')? $param[ 'geometry'] : '+10+10';
  61. $this->_croppos = $this->exists($param, 'croppos')? $param['croppos'] : 'TL';
  62. $this ->_bgcolor = $this->exists($param, 'bgcolor')? $param['bgcolor'] : null;
  63. $this->_quality = $this->exists($param, 'quality ')? $param['quality'] : 90;
  64. $this->_width = $this->exists($param, 'width')? $param['width'] : null;
  65. $this- >_height = $this->exists($param, 'height')? $param['height'] : null;
  66. }
  67. /**Create thumbnail image
  68. * @param String $source original image
  69. * @param String $dest target image
  70. * @return boolean
  71. */
  72. public function create_thumb($source, $ dest){
  73. // Check whether the handler used is installed
  74. if(!$this->check_handler()){
  75. $this->to_log('handler not installed');
  76. return false;
  77. }
  78. // Determine whether the width and height of the area are correct
  79. if(!is_numeric($this->_width) || !is_numeric($this->_height) || $this->_width<=0 || $this- >_height<=0){
  80. $this->to_log('width or height invalid');
  81. return false;
  82. }
  83. // Determine whether the source file exists
  84. if(!file_exists($source)){
  85. $this->to_log($source.' not exists');
  86. return false;
  87. }
  88. // Create target file path
  89. if(!$this->create_dirs($dest)){
  90. $this ->to_log(dirname($dest).' create fail');
  91. return false;
  92. }
  93. $this->_source = $source; // Source file
  94. $this->_dest = $dest; // Target file
  95. // Process the image
  96. switch($this->_type){
  97. case 'fit':
  98. if($this->_handler=='imagemagick'){
  99. return $this-> fit();
  100. }else{
  101. return $this->gd_fit();
  102. }
  103. break;
  104. case 'crop':
  105. if($this->_handler=='imagemagick'){
  106. return $ this->crop();
  107. }else{
  108. return $this->gd_crop();
  109. }
  110. break;
  111. default:
  112. $this->to_log($this->_type.' not fit and crop');
  113. return false;
  114. }
  115. }
  116. /**Compress or stretch the image proportionally
  117. * @return boolean
  118. */
  119. private function fit(){
  120. // Determine whether to fill the background
  121. $bgcolor = ($this->_bgcolor!=null)?
  122. sprintf(" -background '% s' -gravity center -extent '%sx%s' ", $this->_bgcolor, $this->_width, $this->_height) : "";
  123. // Determine whether to convert to RGB
  124. $source_info = getimagesize($this->_source);
  125. $colorspace = (!isset($source_info['channels']) || $source_info['channels']!=3)? ' -colorspace RGB ' : '';
  126. // Command line
  127. $cmd = sprintf("convert -resize '%sx%s' '%s' %s -quality %s %s '%s'", $this->_width, $this->_height, $this->_source, $bgcolor, $this->_quality, $colorspace, $this->_dest);
  128. // Record the executed command
  129. $this->to_log ($cmd);
  130. // Execute command
  131. exec($cmd);
  132. // Add watermark
  133. $this->add_watermark($this->_dest);
  134. return is_file($this-> _dest)? true : false;
  135. }
  136. /**Crop image
  137. * @return boolean
  138. */
  139. private function crop(){
  140. // Get the generated image size
  141. list($pic_w, $pic_h) = $this- >get_size();
  142. // Get the offset of the screenshot
  143. list($offset_w, $offset_h) = $this->get_crop_offset($pic_w, $pic_h);
  144. // Determine whether to convert to RGB
  145. $source_info = getimagesize($this->_source);
  146. $colorspace = (!isset($source_info['channels']) || $source_info['channels']!=3)? ' -colorspace RGB ' : '';
  147. // Command line
  148. $cmd = sprintf("convert -resize '%sx%s' '%s' -quality %s %s -crop %sx%s+%s+%s +repage '%s '", $pic_w, $pic_h, $this->_source, $this->_quality, $colorspace, $this->_width, $this->_height, $offset_w, $offset_h, $this-> ;_dest);
  149. // Record the executed command
  150. $this->to_log($cmd);
  151. // Execute the command
  152. exec($cmd);
  153. // Add watermark
  154. $this->add_watermark ($this->_dest);
  155. return is_file($this->_dest)? true : false;
  156. }
  157. /**GD library compresses or stretches images proportionally
  158. * @return boolean
  159. */
  160. private function gd_fit(){
  161. / / Get the generated image size
  162. list($pic_w, $pic_h) = $this->get_size();
  163. list($owidth, $oheight, $otype) = getimagesize($this->_source);
  164. switch($otype){
  165. case 1: $source_img = imagecreatefromgif($this->_source); break;
  166. case 2: $source_img = imagecreatefromjpeg($this->_source); break;
  167. case 3: $ source_img = imagecreatefrompng($this->_source); break;
  168. default: return false;
  169. }
  170. // Shrink/stretch the image proportionally
  171. $new_img = imagecreatetruecolor($pic_w, $pic_h);
  172. imagecopyresampled( $new_img, $source_img, 0, 0, 0, 0, $pic_w, $pic_h, $owidth, $oheight);
  173. // Determine whether to fill the background
  174. if($this->_bgcolor!=null){
  175. $bg_img = imagecreatetruecolor($this->_width, $this->_height);
  176. $rgb = $this->hex2rgb($this->_bgcolor);
  177. $bgcolor =imagecolorallocate($bg_img, $rgb ['r'], $rgb['g'], $rgb['b']);
  178. imagefill($bg_img, 0, 0, $bgcolor);
  179. imagecopy($bg_img, $new_img, (int)( ($this->_width-$pic_w)/2), (int)(($this->_height-$pic_h)/2), 0, 0, $pic_w, $pic_h);
  180. $new_img = $ bg_img;
  181. }
  182. // Get the type of the target image
  183. $dest_ext = $this->get_file_ext($this->_dest);
  184. // Generate the image
  185. switch($dest_ext){
  186. case 1: imagegif ($new_img, $this->_dest, $this->_quality); break;
  187. case 2: imagejpeg($new_img, $this->_dest, $this->_quality); break;
  188. case 3 : imagepng($new_img, $this->_dest, (int)(($this->_quality-1)/10)); break;
  189. }
  190. if(isset($source_img)){
  191. imagedestroy( $source_img);
  192. }
  193. if(isset($new_img)){
  194. imagedestroy($new_img);
  195. }
  196. // Add watermark
  197. $this->add_watermark($this->_dest);
  198. return is_file($this->_dest)? true : false;
  199. }
  200. /**GD library crop image
  201. * @return boolean
  202. */
  203. private function gd_crop(){
  204. // Get the generated image size
  205. list($pic_w, $pic_h) = $this->get_size();
  206. // Get the offset of the screenshot
  207. list($offset_w, $offset_h) = $this->get_crop_offset($pic_w, $pic_h);
  208. list($owidth, $oheight, $otype) = getimagesize($this-> ;_source);
  209. switch($otype){
  210. case 1: $source_img = imagecreatefromgif($this->_source); break;
  211. case 2: $source_img = imagecreatefromjpeg($this->_source); break;
  212. case 3: $source_img = imagecreatefrompng($this->_source); break;
  213. default: return false;
  214. }
  215. // Shrink/stretch the image proportionally
  216. $tmp_img = imagecreatetruecolor($pic_w, $pic_h );
  217. imagecopyresampled($tmp_img, $source_img, 0, 0, 0, 0, $pic_w, $pic_h, $owidth, $oheight);
  218. // Crop the picture
  219. $new_img = imagecreatetruecolor($this->_width , $this->_height);
  220. imagecopyresampled($new_img, $tmp_img, 0, 0, $offset_w, $offset_h, $this->_width, $this->_height, $this->_width, $ this->_height);
  221. // Get the type of the target image
  222. $dest_ext = $this->get_file_ext($this->_dest);
  223. // Generate the image
  224. switch($dest_ext){
  225. case 1: imagegif($new_img, $this->_dest, $this->_quality); break;
  226. case 2: imagejpeg($new_img, $this->_dest, $this->_quality); break;
  227. case 3: imagepng($new_img, $this->_dest, (int)(($this->_quality-1)/10)); break;
  228. }
  229. if(isset($source_img)){
  230. imagedestroy($source_img);
  231. }
  232. if(isset($tmp_img)){
  233. imagedestroy($tmp_img);
  234. }
  235. if(isset($new_img)){
  236. imagedestroy($new_img);
  237. }
  238. // Add watermark
  239. $this->add_watermark($this->_dest);
  240. return is_file($this->_dest)? true : false;
  241. }
  242. /**Get the size generated by the target image
  243. * @return Array $width, $height
  244. */
  245. private function get_size(){
  246. list($owidth, $oheight) = getimagesize($this->_source);
  247. $width = (int)($this->_width);
  248. $height = ( int)($this->_height);
  249. switch($this->_type){
  250. case 'fit':
  251. $pic_w = $width;
  252. $pic_h = (int)($pic_w*$oheight/ $owidth);
  253. if($pic_h>$height){
  254. $pic_h = $height;
  255. $pic_w = (int)($pic_h*$owidth/$oheight);
  256. }
  257. break;
  258. case 'crop':
  259. if($owidth>$oheight){
  260. $pic_h = $height;
  261. $pic_w = (int)($pic_h*$owidth/$oheight);
  262. }else{
  263. $pic_w = $width;
  264. $pic_h = (int)($pic_w*$oheight/$owidth);
  265. }
  266. break;
  267. }
  268. return array($pic_w, $pic_h);
  269. }
  270. /**Get the offset of the screenshot
  271. * @param int $pic_w Picture width
  272. * @param int $pic_h Picture height
  273. * @return Array $offset_w, $offset_h
  274. */
  275. private function get_crop_offset($pic_w, $pic_h){
  276. $offset_w = 0;
  277. $offset_h = 0;
  278. switch(strtoupper($this->_croppos)){
  279. case 'TL':
  280. $offset_w = 0;
  281. $offset_h = 0;
  282. break;
  283. case 'TM':
  284. $offset_w = (int)(($pic_w-$this->_width)/2);
  285. $offset_h = 0;
  286. break;
  287. case 'TR':
  288. $offset_w = (int)($pic_w-$this->_width);
  289. $offset_h = 0;
  290. break;
  291. case 'ML':
  292. $offset_w = 0;
  293. $offset_h = (int)(($pic_h-$this->_height)/2);
  294. break;
  295. case 'MM':
  296. $offset_w = (int)(($pic_w-$this->_width)/2);
  297. $offset_h = (int)(($pic_h-$this->_height)/2);
  298. break;
  299. case 'MR':
  300. $offset_w = (int)($pic_w-$this->_width);
  301. $offset_h = (int)(($pic_h-$this->_height)/2);
  302. break;
  303. case 'BL':
  304. $offset_w = 0;
  305. $offset_h = (int)($pic_h-$this->_height);
  306. break;
  307. case 'BM':
  308. $offset_w = (int)(($pic_w-$this->_width)/2);
  309. $offset_h = (int)($pic_h-$this->_height);
  310. break;
  311. case 'BR':
  312. $offset_w = (int)($pic_w-$this->_width);
  313. $offset_h = (int)($pic_h-$this->_height);
  314. break;
  315. }
  316. return array($offset_w, $offset_h);
  317. }
  318. /**Add watermark
  319. * @param String $dest image path
  320. */
  321. private function add_watermark($dest){
  322. if($this->_watermark!=null && file_exists($this->_watermark) && file_exists($dest)){
  323. list($owidth, $oheight, $otype) = getimagesize($dest);
  324. list($w, $h, $wtype) = getimagesize($this->_watermark);
  325. // 水印图比原图要小才加水印
  326. if($w<=$owidth && $h<=$oheight){
  327. if($this->_handler=='imagemagick'){ // imagemagick 添加水印
  328. $cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", $this->_gravity, $this->_geometry, $this->_opacity, $this->_watermark, $dest, $dest);
  329. $this->to_log($cmd);
  330. exec($cmd);
  331. }else{ // gd 添加水印
  332. switch($wtype){
  333. case 1: $water_img = imagecreatefromgif($this->_watermark); break;
  334. case 2: $water_img = imagecreatefromjpeg($this->_watermark); break;
  335. case 3: $water_img = imagecreatefrompng($this->_watermark); break;
  336. default: return false;
  337. }
  338. switch($otype){
  339. case 1: $dest_img = imagecreatefromgif($dest); break;
  340. case 2: $dest_img = imagecreatefromjpeg($dest); break;
  341. case 3: $dest_img = imagecreatefrompng($dest); break;
  342. default: return false;
  343. }
  344. // 水印位置
  345. switch(strtolower($this->_gravity)){
  346. case 'northwest':
  347. $posX = 0;
  348. $posY = 0;
  349. break;
  350. case 'north':
  351. $posX = ($owidth - $w) / 2;
  352. $posY = 0;
  353. break;
  354. case 'northeast':
  355. $posX = $owidth - $w;
  356. $posY = 0;
  357. break;
  358. case 'west':
  359. $posX = 0;
  360. $posY = ($oheight - $h) / 2;
  361. break;
  362. case 'center':
  363. $posX = ($owidth - $w) / 2;
  364. $posY = ($oheight - $h) / 2;
  365. break;
  366. case 'east':
  367. $posX = $owidth - $w;
  368. $posY = ($oheight - $h) / 2;
  369. break;
  370. case 'southwest':
  371. $posX = 0;
  372. $posY = $oheight - $h;
  373. break;
  374. case 'south':
  375. $posX = ($owidth - $w) / 2;
  376. $posY = $oheight - $h;
  377. break;
  378. case 'southeast':
  379. $posX = $owidth - $w;
  380. $posY = $oheight - $h;
  381. break;
  382. }
  383. imagealphablending($dest_img, true);
  384. imagecopy($dest_img, $water_img, $posX, $posY, 0, 0, $w, $h);
  385. switch($otype){
  386. case 1:imagegif($dest_img, $dest, $this->_quality); break;
  387. case 2:imagejpeg($dest_img, $dest, $this->_quality); break;
  388. case 3:imagepng($dest_img, $dest, (int)(($this->_quality-1)/10)); break;
  389. }
  390. if(isset($water_img)){
  391. imagedestroy($water_img);
  392. }
  393. if(isset($dest_img)){
  394. imagedestroy($dest_img);
  395. }
  396. }
  397. }
  398. }
  399. }
  400. /**Determine whether the handler is installed
  401. * @return boolean
  402. */
  403. private function check_handler(){
  404. $handler = $this->_handler;
  405. if(!in_array($handler, array('imagemagick', 'gd', null))){
  406. return false;
  407. }
  408. // 检查是否有安装imagemagick
  409. $imagemagick_installed = strstr(shell_exec('convert -version'),'Version: ImageMagick')!=''? true : false;
  410. // 检查是否有安装gd库
  411. $gd_installed = function_exists('gd_info')? true : false;
  412. switch($handler){
  413. case 'imagemagick':
  414. return $imagemagick_installed;
  415. break;
  416. case 'gd':
  417. return $gd_installed;
  418. break;
  419. case null:
  420. if($imagemagick_installed){
  421. $this->_handler = 'imagemagick';
  422. return true;
  423. }
  424. if($gd_installed){
  425. $this->_handler = 'gd';
  426. return true;
  427. }
  428. break;
  429. }
  430. return false;
  431. }
  432. /**Create image directory
  433. * @param String $path
  434. * @return boolean
  435. */
  436. private function create_dirs($dest){
  437. if(!is_dir(dirname($dest))){
  438. return mkdir(dirname($dest), 0777, true);
  439. }
  440. return true;
  441. }
  442. /**Determine whether the parameter exists
  443. * @param Array $obj array object
  444. * @param String $key the key to be found
  445. * @return boolean
  446. */
  447. private function exists($obj,$key=''){
  448. if($key==''){
  449. return isset($obj) && !empty($obj);
  450. }else{
  451. $keys = explode('.',$key);
  452. for($i=0,$max=count($keys); $i<$max; $i++){
  453. if(isset($obj[$keys[$i]])){
  454. $obj = $obj[$keys[$i]];
  455. }else{
  456. return false;
  457. }
  458. }
  459. return isset($obj) && !empty($obj);
  460. }
  461. }
  462. /**Record log
  463. * @param String $msg The log message to be recorded
  464. */
  465. private function to_log($msg){
  466. if($this->_log){
  467. $msg = '['.date('Y-m-d H:i:s').']'.$msg."rn";
  468. file_put_contents($this->_log, $msg, FILE_APPEND);
  469. }
  470. }
  471. /**hex color to rgb color
  472. * @param String $color hex color
  473. * @return Array
  474. */
  475. private function hex2rgb($hexcolor){
  476. $color = str_replace('#', '', $hexcolor);
  477. if (strlen($color) > 3) {
  478. $rgb = array(
  479. 'r' => hexdec(substr($color, 0, 2)),
  480. 'g' => hexdec(substr($color, 2, 2)),
  481. 'b' => hexdec(substr($color, 4, 2))
  482. );
  483. } else {
  484. $r = substr($color, 0, 1) . substr($color, 0, 1);
  485. $g = substr($color, 1, 1) . substr($color, 1, 1);
  486. $b = substr($color, 2, 1) . substr($color, 2, 1);
  487. $rgb = array(
  488. 'r' => hexdec($r),
  489. 'g' => hexdec($g),
  490. 'b' => hexdec($b)
  491. );
  492. }
  493. return $rgb;
  494. }
  495. /**Get the image type
  496. * @param String $file image path
  497. * @return int
  498. */
  499. private function get_file_ext($file){
  500. $filename = basename($file);
  501. list($name, $ext)= explode('.', $filename);
  502. $ext_type = 0;
  503. switch(strtolower($ext)){
  504. case 'jpg':
  505. case 'jpeg':
  506. $ext_type = 2;
  507. break;
  508. case 'gif':
  509. $ext_type = 1;
  510. break;
  511. case 'png':
  512. $ext_type = 3;
  513. break;
  514. }
  515. return $ext_type;
  516. }
  517. } // class end
  518. ?>
  519. demo:
  520. [php] view plaincopy
  521. define('ROOT', dirname(__FILE__));
  522. require(ROOT."/PicThumb.class.php");
  523. $logfile = ROOT.'/PicThumb.log';
  524. $source1 = ROOT.'/pic/source.jpg';
  525. $dest1 = ROOT.'/pic/1.jpg';
  526. $dest2 = ROOT.'/pic/2.gif';
  527. $dest3 = ROOT.'/pic/3.png';
  528. $source2 = ROOT.'/pic/source_cmyk.jpg';
  529. $dest4 = ROOT.'/pic/4.jpg';
  530. $dest5 = ROOT.'/pic/5.gif';
  531. $dest6 = ROOT.'/pic/6.png';
  532. $watermark = ROOT.'/pic/watermark.png';
  533. // 按比例生成缩略图
  534. $param = array(
  535. 'type' => 'fit',
  536. 'width' => 100,
  537. 'height' => 100,
  538. );
  539. $obj = new PicThumb($logfile);
  540. $obj->set_config($param);
  541. $flag = $obj->create_thumb($source1, $dest1);
  542. if($flag){ // bbs.it-home.org
  543. echo '';
  544. }else{
  545. echo 'create thumb fail';
  546. }
  547. // 按比例生成缩略图,不足部分用#FF0000填充
  548. $param = array(
  549. 'type' => 'fit',
  550. 'width' => 100,
  551. 'height' => 100,
  552. 'bgcolor' => '#FFFF00'
  553. );
  554. $obj = new PicThumb($logfile);
  555. $obj->set_config($param);
  556. $flag = $obj->create_thumb($source1, $dest2);
  557. if($flag){
  558. echo '';
  559. }else{
  560. echo 'create thumb fail';
  561. }
  562. // 裁剪250x250的缩略图,裁剪位置是底部中间,水印位置西南,透明度50
  563. $param = array(
  564. 'type' => 'crop',
  565. 'croppos' => 'BM',
  566. 'width' => 250,
  567. 'height' => 250,
  568. 'watermark' => $watermark,
  569. 'opacity' => 50,
  570. 'gravity' => 'SouthWest'
  571. );
  572. $obj = new PicThumb($logfile);
  573. $obj->set_config($param);
  574. $flag = $obj->create_thumb($source1, $dest3);
  575. if($flag){
  576. echo '';
  577. }else{
  578. echo 'create thumb fail';
  579. }
  580. // 按比例生成缩略图 CMYK格式
  581. $param = array(
  582. 'type' => 'fit',
  583. 'width' => 100,
  584. 'height' => 100,
  585. );
  586. $obj = new PicThumb($logfile);
  587. $obj->set_config($param);
  588. $flag = $obj->create_thumb($source2, $dest4);
  589. if($flag){
  590. echo '';
  591. }else{
  592. echo 'create thumb fail';
  593. }

  594. // Generate thumbnails proportionally, fill the missing parts with #FF0000 in CMYK format

  595. $param = array(
  596. 'type' => 'fit',
  597. 'width' => 100,
  598. 'height' => 100,
  599. 'bgcolor' => '#FFFF00'
  600. );
  601. $obj = new PicThumb($logfile);
  602. $obj->set_config($param);
  603. $flag = $obj->create_thumb($source2, $dest5);
  604. if($flag){
  605. echo '';
  606. }else{
  607. echo 'create thumb fail';
  608. }
  609. // Crop a 250x250 thumbnail, the cropping position is the bottom middle, the watermark position is southwest, and the transparency is 50 CMYK format
  610. $param = array(
  611. 'type' => ; 'crop',
  612. 'croppos' => 'BM',
  613. 'width' => 250,
  614. 'height' => 250,
  615. 'watermark' => $watermark,
  616. 'opacity' => ; 50,
  617. 'gravity' => 'SouthWest'
  618. );
  619. $obj = new PicThumb($logfile);
  620. $obj->set_config($param);
  621. $flag = $obj->create_thumb ($source2, $dest6);
  622. if($flag){
  623. echo '';
  624. }else{
  625. echo 'create thumb fail';
  626. }
  627. ?>

Copy code

>>> PHP thumbnail generation class source code download address



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template