如何使用命令行工具为图像添加透明OS X样式边框?

时间:2022-05-12 03:13:59

I have images and want to add a transparent gradient background to them, similar to the way OS X does with window shadows.

我有图像,并希望为它们添加透明渐变背景,类似于OS X对窗口阴影的处理方式。

Is there a way I can use something like mogrify or sips to add this border? The images I want to process are not screenshots, but let me show two screenshots so the effect I'm attempting is clear:

有没有办法可以使用像mogrify或sips这样的东西来添加这个边框?我想要处理的图片不是截图,但让我展示两个截图,所以我尝试的效果很明显:

Flat image:

平面图片:

Picture.png http://img32.imageshack.us/img32/5010/picturexqx.png

Picture.png http://img32.imageshack.us/img32/5010/picturexqx.png

With transparent gradient:

透明渐变:

Picture 1.png http://img684.imageshack.us/img684/6550/picture1ku.png

Picture 1.png http://img684.imageshack.us/img684/6550/picture1ku.png

This doesn't have to be exactly the same, just something similar and not a solid square border.

这不必完全相同,只是类似的东西而不是实心的方形边框。

1 个解决方案

#1


3  

if you say "something similar" is also accepted. try the command below:

如果你说“类似的东西”也被接受。尝试以下命令:

kent$  convert yourPNG.png \( +clone -background black -shadow 50x15+9+15 \) +swap -background none -mosaic +repage new.png

you need have Imagemagic installed.

你需要安装Imagemagic。

the result looks like this:

结果如下所示:

如何使用命令行工具为图像添加透明OS X样式边框?

updated

更新

hope this time it meets your need

希望这次它满足您的需求

kent$  convert yourPng.png \( +clone -background black -shadow 55x15+0+5 \) +swap -background none -layers merge  +repage new.png

result:

结果:

如何使用命令行工具为图像添加透明OS X样式边框?

#1


3  

if you say "something similar" is also accepted. try the command below:

如果你说“类似的东西”也被接受。尝试以下命令:

kent$  convert yourPNG.png \( +clone -background black -shadow 50x15+9+15 \) +swap -background none -mosaic +repage new.png

you need have Imagemagic installed.

你需要安装Imagemagic。

the result looks like this:

结果如下所示:

如何使用命令行工具为图像添加透明OS X样式边框?

updated

更新

hope this time it meets your need

希望这次它满足您的需求

kent$  convert yourPng.png \( +clone -background black -shadow 55x15+0+5 \) +swap -background none -layers merge  +repage new.png

result:

结果:

如何使用命令行工具为图像添加透明OS X样式边框?