falldog 发表于 2017-4-4 13:47:09

用php实现简单的图片组合(合成)

  用gd的imagecopy来实现,代码如下:
  <? php
header(”Content-type: image/jpeg”);
  $source1=imagecreatefromjpeg(”s.jpg”);
$dest1=imagecreatefromjpeg(”d.jpg”);
  imagecopy($dest1,$source1,50,50,0,0,100,100);
  imagejpeg($dest1);
  imagedestroy($dest1);
imagedestroy($source1);
  ?>
  在 图片 上 添加 文字,代码如下:
  <?php
  header(”Content-type: image/jpeg”);
$string = “hello”;
$im    = imagecreatefromjpeg(”images/s.jpg”);
  $orange = imagecolorallocate($im, 220, 210, 60);
$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
  imagejpeg($im);
imagedestroy($im);
  ?>
  相关链接:
利用PHP的GD库生成缩略图
页: [1]
查看完整版本: 用php实现简单的图片组合(合成)