IMAGEMAGICK:标签包含空白时填写 [英] IMAGEMAGICK: Filling when label contains blanks

查看:181
本文介绍了IMAGEMAGICK:标签包含空白时填写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用imagemagick使用Dymo字体创建一些简单的图形。下面是一个例子:

I am using imagemagick to create some simple graphics using the Dymo font. Here is an example:

convert -background White -fill DarkRed -font Dymo -pointsize 72 label:"DYMO FONT" -trim name.png

此命令创建一个如下所示的文件:

This command creates a file that looks like this:

我希望红色一直填满,以便图像看起来像一个单一的标签。我计划在黑色背景的页面上使用它,这使它看起来更糟。

I would like the red to fill all the way across, so that the image looks like a single label. I plan to use this on a page with a black background, which makes it look even worse.

我玩了一段时间没有运气。我们将不胜感激。

I have played around with this for a while with no luck. Help would be appreciated.

版本:ImageMagick 6.9.2-7 Q16 x86_64 2015-12-06

Version: ImageMagick 6.9.2-7 Q16 x86_64 2015-12-06

O / S:Fedora 23

O/S: Fedora 23

推荐答案

我不知道为什么会这样做,但你可以生成你想要的文本用UTF不间断空格替换空格并将其发送到转换 stdin 并询问 -label file中读取其文本 stdin

I don't know why it does that, but you can generate the text you want by replacing the space with a UTF non-breaking space and sending that to the stdin of convert and asking -label to read its text from the "file" called stdin:

printf "DYMO\xc2\xa0FONT" | 
   convert -background white -fill DarkRed -font DYMO -pointsize 72 label:@- result.png

在输出之前添加 -trim 文件名,如果你想要从边缘修剪掉多余的空白区域。

Add -trim just before the output filename if you want the extraneous white space trimmed off from around the edges.

如果你有更复杂的文字并且不想对所有空间都这样做,你可以使用一小段 Perl sed 替换空格为你做...

If you had more complicated text and didn't want to do that for all spaces, you could replace spaces using a short piece of Perl or sed to do it for you...

echo -n "Text with lots of spaces." | sed 's/ /\xC2\xA0/g' | convert -background white -fill DarkRed -font dymo -pointsize 72 label:@- -trim label.png

这篇关于IMAGEMAGICK:标签包含空白时填写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆