2

我正在为打算在 WooCommerce 中销售的产品拍照。我才刚刚开始,现在我用三脚架和照片立方体把它们和我的手机一起带走。质量和照明都很好。

现在看来,我无法将每张图像的三脚架距离保持相同,因此对象可能比其他对象稍小或稍大。

我想要的是一个使用 imagemagick 或 mogrify 之类的命令来(自动)裁剪图像,因此假设产品在现实生活中也具有相似的尺寸,那么所有图像的实际对象的高度和宽度都是相同的。

然后在对象周围添加一点空白,以便每个图像的高度和宽度相同。这样,Woocommerce 将在目录页面上很好地显示它们。

现在有点乱。有些产品在某个区域有太多的空白,这会导致标题错位和页面整体外观不佳。

另外(好像我还没有让它变得足够困难)重要的是图像下方的空白对于所有图像都必须相同,因为图像中的对象必须与其旁边的其他对象保持水平。

我有 4200 张图片需要这个,我非常感谢任何帮助。我使用 debian,更喜欢批处理命令或应用程序。

4

1 回答 1

0

As you haven't provided an image, I have faked one here, with a yellow border. I will do what I think you are asking but using magenta and cyan so you can see the effect - so you will need to replace those colours with white.

enter image description here

First, trim the current border:

convert start.png -trim 1.png

enter image description here

Now add a 100px fixed height strip across the bottom:

convert 1.png -background magenta -gravity south -splice x100 2.png

enter image description here

Now pad left, right and top, but not bottom to a standardised size:

convert 2.png -gravity south -background cyan -extent 500x500 3.png

enter image description here

Of course, you can do all that in one go:

convert start.jpg -trim                            \
   -background magenta -gravity south -splice x100 \
   -gravity south -background cyan -extent 500x500 result.png
于 2016-10-07T23:50:35.047 回答