|
- <?php
- if (!defined('DEDEINC')) exit ('dedebiz');
- require_once DEDEINC."/libraries/imageresize.class.php";
-
-
- if (!function_exists('ImageResize')) {
- function ImageResize($srcFile, $toW, $toH, $toFile = "")
- {
- try{
- $image = new ImageResize($srcFile);
- $image->resizeToBestFit($toW, $toH);
- $image->save($toFile);
- return true;
- } catch (ImageResizeException $e) {
- return false;
- }
- }
- }
-
- if (!function_exists('gdversion')) {
- function gdversion()
- {
-
- if (!function_exists('phpinfo')) {
- if (function_exists('imagecreate')) {
- return '2.0';
- } else {
- return 0;
- }
- } else {
- ob_start();
- phpinfo(8);
- $module_info = ob_get_contents();
- ob_end_clean();
- if (preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info, $matches)) {
- $gdversion_h = $matches[1];
- } else {
- $gdversion_h = 0;
- }
- return $gdversion_h;
- }
- }
- }
-
- if (!function_exists('WaterImg')) {
- function WaterImg($srcFile, $fromGo = 'up')
- {
- include(DEDEDATA.'/mark/inc_photowatermark_config.php');
- require_once(DEDEINC.'/image.class.php');
- if (isset($GLOBALS['needwatermark'])) {
- $photo_markup = $photo_markdown = empty($GLOBALS['needwatermark']) ? '0' : '1';
- }
- if ($photo_markup != '1' || ($fromGo == 'collect' && $photo_markdown != '1')) {
- return;
- }
- $info = '';
- $srcInfo = @getimagesize($srcFile, $info);
- $srcFile_w = $srcInfo[0];
- $srcFile_h = $srcInfo[1];
- if ($srcFile_w < $photo_wwidth || $srcFile_h < $photo_wheight) {
- return;
- }
- if ($fromGo == 'up' && $photo_markup == '0') {
- return;
- }
- if ($fromGo == 'down' && $photo_markdown == '0') {
- return;
- }
- $TRUEMarkimg = DEDEDATA.'/mark/'.$photo_markimg;
- if (!file_exists($TRUEMarkimg) || empty($photo_markimg)) {
- $TRUEMarkimg = "";
- }
- if ($photo_waterpos == 0) {
- $photo_waterpos = rand(1, 9);
- }
- $cfg_watermarktext = array();
- if ($photo_marktype == '2') {
- if (file_exists(DEDEDATA.'/mark/simhei.ttf')) {
- $cfg_watermarktext['fontpath'] = DEDEDATA.'/mark/simhei.ttf';
- } else {
- return;
- }
- }
- $cfg_watermarktext['text'] = $photo_watertext;
- $cfg_watermarktext['size'] = $photo_fontsize;
- $cfg_watermarktext['angle'] = '0';
- $cfg_watermarktext['color'] = '255,255,255';
- $cfg_watermarktext['shadowx'] = '0';
- $cfg_watermarktext['shadowy'] = '0';
- $cfg_watermarktext['shadowcolor'] = '0,0,0';
- $photo_marktrans = 85;
- $img = new image($srcFile, 0, $cfg_watermarktext, $photo_waterpos, $photo_diaphaneity, $photo_wheight, $photo_wwidth, $photo_marktype, $photo_marktrans, $TRUEMarkimg);
- $img->watermark(0);
- }
- }
-
- if (!function_exists('ImageResizeNew')) {
- function ImageResizeNew($srcFile, $toW, $toH, $toFile = '', $issave = TRUE)
- {
- try{
- $image = new ImageResize($srcFile);
- $image->resizeToBestFit($toW, $toH);
- if ($issave) {
- $image->save($toFile);
- } else {
- $image->output();
- }
- return true;
- } catch (ImageResizeException $e) {
- return false;
- }
- }
- }
|