我想从一个文件夹中拿一个简单的图像文件(500px宽度的例子),在PHP中执行(‘/usr/bin/convert -etc.')添加到图像中并实现这一点:http://imm.io/media/3O/3O7j.jpg。基本上,我想在图像周围的特定位置绘制2个彩色边框/矩形。任何人都可以帮助编写这样的命令,或者这是可能的?
谢谢。
发布于 2011-02-18 09:45:13
在PHP中使用GD扩展可能会更容易。具体地说,imagesetstyle()函数用于设置划线,imageline()函数用于绘制线条。
此示例加载一幅图像并在其上绘制一条虚线。您应该能够根据您的需要对其进行调整。
<?php
$im = imagecreatefromjpeg('/your/file.jpg');
$w = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
/* Draw a dashed line, 5 red pixels, 5 white pixels */
$style = array($red, $red, $red, $red, $red, $w, $w, $w, $w, $w);
imagesetstyle($im, $style);
imageline($im, 0, 0, 100, 100, IMG_COLOR_STYLED);
imagejpeg($im, '/path/to/save.jpg');
imagedestroy($im);
?>https://stackoverflow.com/questions/5036682
复制相似问题