Imagemagick PHP GD或Imagick类图像Magick转换

Imagemagick PHP GD或Imagick类图像Magick转换,imagemagick,gd,image-manipulation,imagick,imagemagick-convert,Imagemagick,Gd,Image Manipulation,Imagick,Imagemagick Convert,我需要将一些命令行imagick代码转换成php类。我不能在我们的生产设备上运行命令行脚本,所以我需要能够使用这些类,不幸的是,没有关于在这两个类之间转换的文档 有人知道我如何使用imagick类来实现这一点吗 $color\u mask=“convert-size$dimensions xc:#$color-fill white”; /*创造银色面具*/ $silver_mask=“转换-尺寸$dimensions xc:#e6e7e8-填充白色”; /*在将图像裁剪到尺寸以获得“放大”效果之

我需要将一些命令行imagick代码转换成php类。我不能在我们的生产设备上运行命令行脚本,所以我需要能够使用这些类,不幸的是,没有关于在这两个类之间转换的文档

有人知道我如何使用imagick类来实现这一点吗

$color\u mask=“convert-size$dimensions xc:#$color-fill white”;
/*创造银色面具*/
$silver_mask=“转换-尺寸$dimensions xc:#e6e7e8-填充白色”;
/*在将图像裁剪到尺寸以获得“放大”效果之前,将图像大小调整为$LORGER_dim*/
$thumb=“转换图像/$im-缩略图$magner\u dim^”。
“-重心-范围$dimensions PNG:-”;
/*屏幕显示调整大小的缩略图和颜色遮罩*/
$masked=“convert$thumb$color_mask-合成屏幕-重心-合成PNG:-”;
/*将戴面具的拇指与银色面具相乘*/
$final=“convert$masked$silver_mask-合成倍增-重心-合成PNG:-”;
/*输出图像*/
标题(“内容类型:图像/png”);
直通($final,$retval);
我也很乐意在GD中做同样的事情,我只是在GD中遇到了质量问题


TIA

好的,这需要花很多时间才能弄清楚,因为php.net上的文档不是很好,而且没有任何地方可以解释ImageMagick命令行和Imagick php类中的函数之间的等效函数

以下是我执行上述操作的函数:

public static function getColorImg($img, $color, $filename) {

if (class_exists('Imagick')) {

  // Create the blue overlay
  $blue = new Imagick();

  // Create a plain colour image in the selected color
  $blue->newImage($dimensions['width'], $dimensions['height'], new ImagickPixel($color));
  $blue->setImageFormat('png');

  // Create the plain grey image
  $grey  = new Imagick();
  $grey->newImage($dimensions['width'], $dimensions['height'], new ImagickPixel($silver));
  $grey->setImageFormat('png');

  // Now grab the actual image and change it's size to the larger image
  $image = new Imagick($img);
  $image->setImageFormat('png');
  $image->thumbnailImage($larger_dim['width'], $larger_dim['height'], TRUE);
  // now zoom it in
  $image->cropThumbnailImage($dimensions['width'], $dimensions['height']);
  // Screen takes multiple commands in the php class. Negate the two images
  $image->negateImage(false);
  $blue->negateImage(false);
  // Then multipy them.
  $image->compositeImage($blue, imagick::COMPOSITE_MULTIPLY, 0, 0);
  // Re nagate the image so that it looks back to normal.
  $image->negateImage(false);
  // Now multiply it with the silver image
  $image->compositeImage($grey, imagick::COMPOSITE_MULTIPLY, 0, 0);
  // Write out the file as original file name with the prefix
  if ($image->writeImage($filename)) {
    $return = $filename;
  }
  else {
    $return = FALSE;
  }
}
else {
  $return = FALSE;
}

return $return;
}