随着Graphicsmagick,如何结合2图像和文本在一定的格式?(With Graphicsmagick, how to combine 2 images and text in a certai

编程入门 行业动态 更新时间:2024-10-23 06:23:03
随着Graphicsmagick,如何结合2图像和文本在一定的格式?(With Graphicsmagick, how to combine 2 images and text in a certain format?)

我需要将两幅图像和一段短文本合并成一幅图像,格式为第一幅图像位于顶部,另一幅图像位于底部左侧,右下角的文本位于顶部。

生成的图像是400px * 600px,输入图像可以是任何尺寸,如果第一个图像小于400px,它将会位于顶部

Graphicsmagick有可能吗?

I need to combine 2 images and a short text into one image, in the format that the first image is at the top spanning a row, and the other image at bottom left, the text at bottom right.

The produced image is 400px * 600px, the input images can be any size, if the first image is less than 400px, it will be centered at the top

Is it possible with Graphicsmagick?

最满意答案

假设你已经有两个图像叫做:

top.png (顶部的图像横跨一行) left.png左下角的其他图片)

首先,您必须创建包含文字的第三个缺失图像(称为text.png ):

gm convert -size 200x300 xc:#7F0000 -pointsize 80 -font Arial -fill white -draw "text 10,150 'text'" text.png

那么你可以在底部构成两个图像(创建一个名为bottom.png的图像):

gm montage left.png -geometry 200x300+0+0 text.png -tile 2x1 bottom.png

最后你可以用上面和下面的部分组成:

gm montage top.png -geometry 400x300+0+0 bottom.png -tile 1x2 result.png

结果将是一个名为result.png的图像,大小:400x600

top.png:

在这里输入图像描述

left.png:

在这里输入图像描述

result.png:

在这里输入图像描述

使用GraphicsMagick 1.3.18测试Windows 2013-03-10 Q8

Assuming you already have two images called:

top.png (image at the top spanning a row) left.png (other image at bottom left)

first of all you have to create the third missing image (called text.png) containing your text:

gm convert -size 200x300 xc:#7F0000 -pointsize 80 -font Arial -fill white -draw "text 10,150 'text'" text.png

then you can compose the two images in the bottom part (creating an image called bottom.png):

gm montage left.png -geometry 200x300+0+0 text.png -tile 2x1 bottom.png

and finally you can compose upper and lower parts with:

gm montage top.png -geometry 400x300+0+0 bottom.png -tile 1x2 result.png

the result will be an image called result.png, size: 400x600

top.png:

enter image description here

left.png:

enter image description here

result.png:

enter image description here

Tested on Windows with GraphicsMagick 1.3.18 2013-03-10 Q8

更多推荐

本文发布于:2023-07-23 18:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1235603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在一   图像   文本   格式   Graphicsmagick

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!