I have this code in ImageMagick, it works except for changing the font. I tried all kinds of options, I don't understand what I could do to change the font to the font I want.
Besides that, how can I give opacity to ``-undercolor "#E70E0E"```?
magick convert 13.jpg -fill white -undercolor "#E70E0E" -gravity Center -font "Comic Sans MS" -pointsize "75" -annotate +0+5 "Title-text" -gravity Center -pointsize "25" -font "Calibri Light" -annotate +0+100 "SubTitle-Text" -crop 1920x1080+0+0 -scale 1920x1080+0+0 picture.jpg
thank you so much
Possibly missing dashes in the font names (Calibri-Light).
You can list the fonts known to IM using magick identify -list font.
Related
I have a number of PNG image files that I'd like to increase in size. I do not want to rescale the image. I just want to extend the white background further down and to the right. In GIMP terms what I want is to increase the Canvas Size, and cover the increased area with white pixels, in a batch context. The input images may be different sizes, but the output images should all be a fixed size (e.g.: 1280 x 720 pixels).
I've tried this with various online tools, with GIMP, and with a very old version of Photoshop. Most of the tools I've tried to date do one of the following which I don't want:
Rescale the existing image to cover the new canvas size, or
Center the starting image and extend the canvas in all directions, or
Fail to perform this in a batch mode.
I just want to extend existing PNG images with additional white pixels down and to the right. What's the easiest way to do this to a large number of files?
imagemagick is a common tool for this. the -crop operation combined with -gravity can probably do what you want.
magick input.jpg -crop 1000x1000+0+0\! -background white -flatten output.png
source for the magick spell: https://legacy.imagemagick.org/Usage/crop/
In ImageMagick, you process a whole folder of images using mogrify. You can extend them using -extent. With mogrify, it is wise to first create a new empty directory to hold the results. So
cd image_directory
mogrify -format png -path path/to/new_directory -background white -gravity northwest -extent WxH *.png
Where WxH, is your desired final width and height after padding with the white. This assumes that all images will be padded to the same width and height
Expand By Size
cd test1
mogrify -format png -path ../test2 -background white -gravity northwest -extent 500x500 *.jpg
Expand By Percent
cd test1
mogrify -format png -path ../test2 -background white -gravity northwest -extent 150x150% *.jpg
For ImageMagick 7, add magick before mogrify. So "magick mogrify ..."
The ImageMagick command that did what I needed used "convert" with the -geometry and -composite arguments. In a Windows batch file context:
for %%a in (img*.png) do (
magick convert -size 1280x720 xc:white "%%a" -geometry 512x384+40+40 -composite "work-%%~na.pdf"
)
I need to annotate some label/text containing greek letters on a figure using convert from imagemagick on linux.
What is the best option?
Trivial choices such as:
ii=1
label="α β $ii"
convert in.png -fill black -annotate "$label" out.png
won't work.
I am not familiar with font coding options.
One way that works for me in ImageMagick 6.9.9.23 Mac OSX Sierra is to use a Greek font. (The symbol font also works)
ii=1
label="a b $ii"
convert logo: -font GreekMathSymbols -pointsize 64 -gravity center -fill red -annotate +0+0 "$label" out.png
Alternately, use a UTF-8 compatible text editor and type your text using a font that supports those characters. For example I put your alpha beta one characters into a text file using the same GreekMathSymbols font.
Then
convert logo: -font GreekMathSymbols -pointsize 64 -gravity center -fill red -annotate +0+0 "#greek.txt" out2.png
See also http://www.imagemagick.org/Usage/text/#unicode
I need to count pixels in an image that are not background color.
I am calling this from PHP (it's from ImageMagick):
gm convert test.png -fill black +opaque "rgb(255,255,255)" -fill white -opaque "rgb(255,255,255)" -print "pixels = %[fx:w*h*mean]\n"
But it does not give any result, nothing.
I tried using histogram instead:
gm convert test.png -define histogram:unique-colors=true -format %c histogram:info.txt
That works, but gives values for every color and more details, I just need a single number please.
You have got a couple of issues here. You seem to be trying to mix GraphicsMagick with ImageMagick when they are not the same thing.
Firstly, GraphicsMagick does not have the +opaque operator that ImageMagick has.
Secondly, it doesn't have the -fx operator that ImageMagick has for doing maths.
I would suggest you move to, the more powerful, ImageMagick. Then it will work as you expect:
# Create a test image
convert -size 200x200 xc:black xc:white xc:red +append image.png
# Count the white pixels
convert image.png -fill black +opaque "rgb(255,255,255)" -print "pixels = %[fx:w*h*mean]\n" nul:
pixels = 40000
If you really, really must do it with GraphicsMagick, I can only suggest the following - which is heavily based on #GlennRanders-Pehrson answer here:
gm convert image.png +matte -matte -transparent white -operator matte negate 1 result.png
gm identify -verbose result.png | grep -EA5 "Opacity:|Geometry:" | grep -E "Mean|Geometry"
Geometry: 600x200
Mean: 43690.00 (0.6667)
Mean: 43690.00 (0.6667)
And your answer will be:
600 * 200 * (1 - 0.667)
I am trying to take an image, say front2.jpg and add "Hello World" arc'd across the top. But I can't seem to figure out how to get this working. I'm getting an errror
-bash: syntax error near unexpected token `('
Command
convert front5.jpg (-gravity north -pointsize 40 -fill '#ffffff' -background none label:'Hello World' -virtual-pixel transparent -distort Arc 320) -geometry +0+0 -composite front2.jpg
Like bash is trying to tell you: take out the parentheses.
convert front5.jpg -gravity north -pointsize 40 -fill '#ffffff' -background none label:'Hello World' -virtual-pixel transparent -distort Arc 320 -geometry +0+0 -composite front2.jpg
I grabbed a random jpg and tried this command on it and got a neat little text arc (that's a pretty cool effect by the way) on the result.
It also works if you escape the parens, but I can't find any noticeable difference in the result, so I'd just use the first one for simplicity.
convert front5.jpg \( -gravity north -pointsize 40 -fill '#ffffff' -background none label:'Hello World' -virtual-pixel transparent -distort Arc 320 \) -geometry +0+0 -composite front2.jpg
I want to convert given text, say TEST, to image in different font and style.
I am using Imagemagick's convert command
convert -pointsize 120 -font Courier label:'TEST' test.png
But when I am using -style in the same, it is not changing into different style like Normal, Bold, Italic.
Please suggest how to get all 3 style.
I think -style (e.g. Italic) and -weight (e.g. Bold) only work for certain fonts like postscript ones (unable to quote you a definitive source though).
What I use is fonts like Courier-New-Bold, Courier-New-Italic, Courier-New-Bold-Italic.
e.g.:
convert -pointsize 120 -font Courier label:'TEST' test.png
convert -pointsize 120 -font Courier-New-Bold label:'TEST' testbold.png
convert -pointsize 120 -font Courier-New-Italic label:'TEST' testitalic.png
convert -pointsize 120 -font Courier-New-Bold-Italic label:'TEST' testbolditalic.png
Most fonts have the -Bold, -Italic, and -Bold-Italic versions.
To see what fonts you can use, do convert -list font (or convert -list type if your ImageMagick is older). I do convert -list font | grep Font: to get a condensed list of just font names.