WordPress数据库错误: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `wp_options`

WordPress数据库错误: [Got error 28 from storage engine]
SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format') AND tr.object_id IN (1) ORDER BY t.name ASC

PHP图片处理生成缩略图加水印 – Crazy knowledge base
Crazy knowledge base

PHP图片处理生成缩略图加水印

$mgConf['serverpath'] = "D:/workspace/php/mygallery";
$mgConf['watermarkimg'] = "watermark.png";

$mgConf['watermark_x'] = -95;
$mgConf['watermark_y'] = -40;
$mgConf['watermark_transparency'] = 100;

if (mkthumbnail("images/1/george_michael_george_michael_1.jpg", "images/thumb_george_michael_george_michael_1.jpg", "c", 90, 90, 85))
{
 echo "成功图片生成";
}else{
 echo "失败";
}

function mkthumbnail($src, $dst, $mode="w", $width, $height, $quality=80, $watermark=false){
 $info = getimagesize($src);
 $cropmode = false;
 global $mgConf;
 
 if ($info[2] == 2){ // if it's jpg
 
  $srcx = 0;
  $srcy = 0;
  $srcw = $info[0];
  $srch = $info[1];
  $destw = $width;
  $desth = $height;
 
  if ($mode == "w"){
   $destw = $width;
   $desth = round(($info[1]*$width)/$info[0], 0);
  
  }else if ($mode == "h"){
   $desth=$height;
   $destw=round(($info[0]*$height)/$info[1], 0);
   
  }else if ($mode == "m"){
   // landscape
   if ($srcw > $srch){
    $destw = $width;
    $desth = round(($info[1]*$width)/$info[0], 0);    
   // portrait
   }else{
    $desth=$height;
    $destw=round(($info[0]*$height)/$info[1], 0);
   }
  
  
  // crop image
  }else if ($mode == "c"){
   
   // thumb is square
   if ($width == $height){
    if ($srcw > $srch) $cropmode = "w";
    else $cropmode = "h";   
   // thumb is landscape
   }else if ($width > $height){
    $cropmode = "h";
   // thumb is portrait
   }else{
    $cropmode = "w";
   } 
   
   
   if ($cropmode == "w"){
    $srcw = round(($width*$srch) / $height, 0);
    $srcx = floor(($info[0] - $srcw) / 2);     
   }else if ($cropmode == "h"){
    $srch = round(($height*$srcw) / $width, 0);
    $srcy = floor(($info[1] - $srch) / 2);
   }
 
  }
  
  $src_p=imagecreatefromjpeg($src);
  $dst_p=imagecreatetruecolor($destw, $desth);
  imagecopyresampled($dst_p, $src_p, 0, 0, $srcx, $srcy, $destw, $desth, $srcw, $srch);
  
  // add watermark
  if ($watermark === true && $mgConf['watermarkimg'] != ""){
   waterMark($dst_p, $mgConf['watermarkimg']);  
  }
  
  imagejpeg($dst_p, $dst, $quality);
  imagedestroy($src_p);  
  imagedestroy($dst_p); 
  return true; 
 }else return false;
}
function waterMark(&$sourcefile_id, $watermarkfile) {
 global $mgConf;

 $watermarkfile = $mgConf['serverpath']."/".$watermarkfile;
  
    //Get the resource ids of the pictures
    $watermarkfile_id = imagecreatefrompng($watermarkfile);
  
    imageAlphaBlending($watermarkfile_id, false);
    imageSaveAlpha($watermarkfile_id, true);

 // get destination position of wm image
 $dest_x = ($mgConf['watermark_x'] < 0) ? imagesx($sourcefile_id) + $mgConf['watermark_x'] : $mgConf['watermark_x'];
 $dest_y = ($mgConf['watermark_y'] < 0) ? imagesy($sourcefile_id) + $mgConf['watermark_y'] : $mgConf['watermark_y'];
  
    imagecopy($sourcefile_id, $watermarkfile_id, $dest_x, $dest_y, 0, 0, imagesx($watermarkfile_id), imagesy($watermarkfile_id));
}
PHP图片处理生成缩略图加水印

WordPress数据库错误: [Got error 28 from storage engine]
SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (3) ORDER BY t.name ASC

5条评论在“PHP图片处理生成缩略图加水印

评论已关闭。

滚动到顶部