【发布时间】:2015-02-05 06:31:15
【问题描述】:
我正在尝试使用 imagick 扩展将这个 Imagemagick whiteboard cleaning script 转换为纯 PHP,以避免不得不使用 exec 等生成进程。
原始 bash 脚本:
#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2
我正在为最初的 Convolve 形态核矩阵苦苦挣扎,我认为其他一切似乎都有效:
<?php
$channel = null;
$convolveKernel = array(15, 100, 0);
$negateGreys = false;
$blurRadius = 0;
$blurSigma = 1;
$levelBlack = 60; // 60%
$levelGamma = 0.1;
$levelWhite = 91; // 91%
$image = new Imagick($file);
try {
$image->convolveImage($convolveKernel, $channel);
$image->negateImage($negateGreys, $channel);
$image->normalizeImage($channel);
$image->blurImage($blurRadius, $blurSigma, $channel);
$image->levelImage($levelBlack, $levelGamma, $levelWhite, $channel);
header('Content-type: image/jpeg');
echo $image;
} catch (ImagickException $e) {
echo $e->getMessage();
}
我遇到了一个例外 "The kernel must contain a square number of elements",但我也想知道黑白电平值的比例 - 这些是 0-100、0-255 还是 0-65535?
【问题讨论】:
标签: php imagemagick imagemagick-convert