【问题标题】:insert image into another image Imagick [closed]将图像插入另一个图像Imagick [关闭]
【发布时间】:2014-03-21 03:13:00
【问题描述】:

我需要使用 Imagick php 创建一个具有一定尺寸(45 厘米宽 x 32 厘米高)的白色背景的图像,并将他复制到我在某个固定位置的文件夹中的图像中。

我可以帮忙吗?

一个问候,非常感谢你

【问题讨论】:

标签: php imagick


【解决方案1】:

imagecopy是你需要的功能

裁剪图像示例:

<?php
// Create image instances
$src = imagecreatefromgif('php.gif');
$dest = imagecreatetruecolor(80, 40);

// Copy
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40);

// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);
?>

如果您只需要添加白色背景imagefill 是您的功能:

$image = imagecreatetruecolor(100, 100);

// set background to white
$white = imagecolorallocate($im, 255, 255, 255);
imagefill($image, 0, 0, $white);

【讨论】:

  • 好的,稍微编辑一下这个解决方案,我曾经做我想做的事。一个问候,非常感谢你
  • 这段代码生成一个黑色背景的图像,就像我有白色背景一样?
  • 添加了白色背景所需的代码
  • 我爱你,你知道吗?? xDxD 最后一件事,新的图像只有 72 DPI,如何将其更改为 300 DPI?
  • 看看这个:stackoverflow.com/questions/17585457/… 除非你支持我的回答,否则我不知道你是否爱我:P
猜你喜欢
  • 1970-01-01
  • 2021-10-05
  • 2013-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多