I'm trying to create label using ImageMagick with the next command from https://legacy.imagemagick.org/Usage/text/
convert 'label:Some test label' label.png
The image is
Adding -pointsize does nothing on this issue. But if I set -size, the image is exactly of that size with text that fits to the canvas.
Previously I've used this, but now something goes wrong. How can I fix it without setting size?
Ubuntu 21.10
ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25
EDIT:
Setting -pointsize
convert -pointsize 108 'label:Some test label' label.png
Produces
Setting -size
convert -size 100x100 'label:Some test label' label.png
I want to use -pointsize but something goes wrong.
EDIT2:
I've found that setting -font explicitly works well
convert -pointsize 108 -font Liberation-Sans 'label:Some test label' label.png
Related
I'd like to draw a text onto an image in a way like this:
convert -quality 100 -font Oswald-Regular -pointsize 515 -fill black -draw "text 1339.0,1099 'some text'" /tmp/ascript.png /tmp/ascript.png
and I need to know the dimensions of the text with the above parameters (size, font, text). How can I get that?
I tried something like this:
convert -size 5000x1500 xc:lightblue -font Oswald-Regular -pointsize 515 -fill none -undercolor white -annotate +20+100 'some text' -trim info:
but it's giving false result:
xc:lightblue XC 1834x250 5000x1500+19+0 16-bit sRGB 0.010u 0:00.000
.
What is the proper way (or a working way) to get the dimension of a drawn image based on this 3 parameters (font, size, text)?
I'm not strictly binded to ImageMagick, it can be any command line tool for the Linux shell, however, the text will be drawn by convert.
There are a couple simple ways to get the dimensions using ImageMagick with commands like this...
convert -size 5000x1500 xc:lightblue -font Oswald-Regular -pointsize 515 \
-fill none -undercolor white -annotate +20+100 'some text' \
-format "%[#]\n" info:
That uses the FX escape "%#" as the formatting string for the "info:" output. It will show IM's calculation of the after-trim width, height, horizontal offset, and vertical offset like "WxH+X+Y".
This similar command just gives the width and height of the trimmed text...
convert -size 5000x1500 xc:lightblue -font Oswald-Regular -pointsize 515 \
-fill none -undercolor white -annotate +20+100 'some text' \
-trim +repage -format "%[w]x%[h]\n" info:
That will trim the text, reset the paging geometry with "+repage", then output a string showing "WxH".
––– Edited to Add –––
I tried your image with_text.png with these commands. The output immediately follows each command...
convert with_text.png -format "%[#]\n" info:
1807x389+512+115
convert with_text.png -trim +repage -format "%[w]x%[h]\n" info:
1807x389
Those were tested with IMv6.8.9-9 on ubuntu bash on Windows 10. If you use that actual image and those commands, I'm not sure why you would get different results.
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.
Version: ImageMagick 6.9.2-7 Q16 x86_64 2015-12-06
O/S: Fedora 23
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
Add -trim just before the output filename if you want the extraneous white space trimmed off from around the edges.
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
I'm trying to generate an image using Imagemagick to match a preview in the browser, but the text comes out blurry. Does anybody have any suggestions? Attached is an image with the Imagemagick one on top, and browser one on bottom, along with the IM code.
convert -density 288 -resize 25% -background white -fill black -strokewidth 0 -stroke white -font Rubik-Regular.ttf -pointsize 10 -gravity center label:'This is a TEST!' label_arial.gif
You might find it easier to start with caption which automatically sizes the text the best way to fill a given area. So, as your lettering is around 140x36 pixels, you would do:
convert -size 140x36 -gravity center caption:'This is a TEST!' label.gif
I'm after a very specific conversion result from Imagemagick, taking something like this:
And converting it into something like this (1140 pixels wide, 12px border around the top, left, and right of the original):
So far I'm using this code to convert it:
convert nike.jpg -colorspace RGB -density 72 -gravity west -background white -extent 1140x104 nike2.jpg
But I'm getting this very skewed result:
Any advice on how to get closer to my goal here? I guess I'm trying to chain Imagemagick commands here to reduce the size to 78px high, add a 12px border, then extend the background on the right to 1140px wide, and I'm not really sure how to chain commands in Imagemagick via Paperclip.
Solved perfectly:
convert nike.jpg -colorspace RGB -density 72 -resize 78 -gravity west -bordercolor white -border 12x12 -background white -extent 1140x104 nike3.jpg
I need to be able to apply watermark on an image, using either text or another image.
Getting it to work with an image was quite straight forward, using the following command:
gm composite -dissolve 15 -tile logo.png image.jpg wmark_tiled.jpg
Now, I also want to be able to use text for watermarking (in other cases). The only thing that I found close to it, is a command from ImageMagick tutorial which is the following :
convert -size 140x80 xc:none -fill grey -gravity NorthWest -draw "text 10,10 'copyrigh text'" -gravity SouthEast -draw "text 5,15 'copyright text'" miff:- | gm composite -tile - image.jpg copyrightImage.jpg
Although its not working in GM, and I would rather avoid using pipe as it causes some headaches managing it from Java.
What I thought I could do, is generate an image from a given text, and then use that image as logo.png is used on my first command. Although I cannot find how to generate an image out of text, all I find is putting text on top of an image.
Ideally I will generate a transparent image with the text, and from what I see modifying font/color etc should be quite flexible.
Any suggestions on how to achieve this, or any better solutions are welcome.
(I added imagemagick tag as the interfaces are often same/similar)
I'm not sure I fully understand your query, so apologies if I've misunderstood, but are you trying to create a transparent image, with some text in the corner? If so, would this not work?
convert -background transparent -fill grey -font Calibri -size 140x80 -pointsize 14 -gravity southeast label:'copyright text' output.png
Obviously adjusting the font, pointsize, output image name etc. That would create the following:
http://oi42.tinypic.com/14j1bvp.jpg
P.S. that was written for ImageMagick. I don't know how GM differs or whether it would still work.
To be able to get the watermark text into the same image I had to use the -annotate parameter.
So Moogle's code snippet would look like this in my case:
convert original_image.jpg -background transparent -fill grey -font Calibri -size 140x80 -pointsize 14 -gravity southeast -annotate +0+0 'copyright text' output.jpg