ImageMagick Draw Text Not Working In Mountain Lion - imagemagick

Just upgraded ImageMagick to 6.8.0-19 on my Mac and the drawing of text has suddenly stopped working. The current code is:
system("convert #{output.path} -fill black -pointsize 26 -gravity SouthWest -draw \"text 30,8 #{string}\" #{output.path}")
When I push my code to Heroku (running ImageMagick 6.5.7-8), the text still gets rendered fine. Anyone knows what's wrong?

Related

ImageMagick creates imag with 1px height

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

graphicsmagick draw rectangle - converting from imagemagick

I am trying to convert all my Imagemagick code over to GraphicsMagick to help speed up the process since we do about 5 a second. Just about everything worked just by changing out convert command to gm convert. But can't figure out why this one will not draw the rectangle.
gm convert /MYIMAGE.jpg \ -fill '#0007' -draw 'rectangle 0,342,508,392' \ -gravity North -pointsize \ 18 -fill white -annotate +0+350 'My Image Text Here' \ /MYIMAGE.jpg
I have been playing with it for hours and bee on their site all morning. Can't really see what the issue is. Like I said, every single of my other actions work perfect in GM. So not a issue with GM running, just something different from ImageMagick that im not seeing. Any help appreciated :)
I think your answer is here: http://www.graphicsmagick.org/api/draw.html#drawrectangle
Also changing your Imagemagick install from a 16bit one to a 8bit may improve speed as I belive that is one reason graphicsmagick is faster.
EDIT:
You need to specify all the relavent information when you ask a question.
Anyway why do you have all the backslashes in your code?

Generating small text with Imagemagick is blurry

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

How do I avoid this ImageMagick anti-aliasing discoloration?

Update:
Thanks to a suggestion from paddy, it has come to my attention that the anti-aliasing looks fine on one of my machines, but not the other.
I'm trying to create a 24x24 png that features a filled shape with a transparent background. Here is the command I am working with:
convert -size 24x24 xc:none \
-fill red \
-draw "path 'M 0,0 L 24,0 A 24,24 0 0,0 0,24 Z' " result.png
"xc: _____" specifies a background color. (maybe this is where I'm mistaken?)
The output gives me the correct shape, but the border between the shape and the transparent area (i.e. the anti-aliased edge between color and transparency) is noticeably darkened:
The anti-aliasing shown on the right is what I want from ImageMagick. Here's what I get for different values of xc:
As you can see, the anti-aliasing blends fine with solid colors, but not with transparency. The ImageMagick guide has a section on anti-aliasing and the problems it can cause, but reading through it, none of it's examples cover transparency. Any ideas?
Have you tried setting -background Red -alpha Background? I suspect that the background color is defaulting to black, which is then being blurred with the red against the transparent background.
Try xc:transparent over xc:none
convert -size 24x24 xc:transparent \
-fill red \
-draw "path 'M 0,0 L 24,0 A 24,24 0 0,0 0,24 Z' " result.png
As #paddy pointed out in the comments, this issue was resolved in later versions of IM
Updating to a more recent version of ImageMagick/convert (6.9.1-6 Q16 i686 2015-06-30) fixed the problem for me. (Thanks, paddy)

Apply watermark with text / image using GraphicsMagick

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

Resources