i'm generating text images with following command sequence
convert -background "rgb(233, 231, 218)" -fill black \
-font media/fonts/FuturaStd-Medium.otf \
-pointsize 13 label:"ğüşıöçĞÜŞİÖÇ" -size 88x18 \
media/images/category_images/food-drink/category-top-row/tr_food-drink.png
which generates the following image.
alt text http://img54.imageshack.us/img54/5461/trfooddrinkai3.png
ğşĞİŞ are problematic, where others display correctly. my locale is en_US.UTF-8.
i'm also not having any problems trying the following example pinched from http://www.imagemagick.org/Usage/text/#unicode
convert -background lightblue -fill blue -pointsize 32 \
label:' é è à ù ç Ö ÿ ‘ ’ “ ” ° ² ³ € x ÷ ' label_i8n.gif
unicode characters displayed correctly in the label_i8n.gif.
how can i make imagemagick correctly convert these characters to image?
edit: following image is created with gimp using the same font. alt text http://img93.imageshack.us/img93/1986/gimpfuturastdnc4.png
Probably the font doesn't have those glyphs, and that's why they are displayed as "?". Check it with the Character Map application.
Related
Absolut beginner here.
I got the task to write a workflow to run on a server for a web-platform that uses RoR. Server is linux based.
I want to create an image. Basically, it's a background picture, already on the server, with two green squares, one in the down left and one in the right down corner. Inside the green squares is white text from two input fields on the website (left input text and right input text).
The user uploads a logo of their sports team to be resized and fitted into the upper-right corner.
I would basically do it like:
convert -background none -fill white -font Helvetica -pointsize 100 -size 450x -gravity center caption:“text right input“ right.png
convert -background none -fill white -font Helvetica -pointsize 100 -size 450x -gravity center caption:“text left input“ left.png
composite -gravity Center left.png base.png left_done.png
composite -gravity Center right.png base.png right_done.png
composite -gravity southeast right_done.png background.png bg_right.png
composite -gravity southwest left_done.png bg_right.png bg_left_right.png
convert Logo-upload.jpg -resize 400x230 logo_resized.png
composite -gravity NorthEast logo_resized.png bg_left_right.png done.png
This is step by step command line, how I would do it.
But there must be a more efficient way, isn't it?
I would love to here your comments. Just started out with very basic tasks programming very elementary things. Would love to learn more.
//Edit: The workflow may seem weird, but it was the easiest for me to get it pixel perfect on the background.png (1000x500px)
You can do that in one command line in ImageMagick, if you use parentheses processing. Here is an example using ImageMagick 6 in Unix syntax. See https://legacy.imagemagick.org/Usage/basics/#parenthesis
Input:
Logo:
convert IMG0005.jpg \
\( -size 450x -background green1 -fill white -font Helvetica -pointsize 100 -gravity center caption:"text right input" \) \
-gravity southeast -compose over -composite \
\( -size 450x -background green1 -fill white -font Helvetica -pointsize 100 -gravity center caption:"text left input" \) \
-gravity southwest -compose over -composite \
\( olympic-logo.gif -resize 400x230 \) \
-gravity northeast -compose over -composite \
IMG0005_composite.jpg
Result:
If on Windows, remove the back-slashes from the parentheses and change the end of line back-slash to ^.
If on ImageMagick 7, change "convert" to "magick"
When I try to draw text using imagemagick compound letters show as splitted. For example the word ഉത്തരം shows as ഉത് തരം without space in it.
PS: I can't write here without space as it will show as normal compound letter.
My Sublime text editor also have this problem. But in Visual studio code, it works correctly. The commands I tried below:
magick -size 1040x1310 gradient:tomato-steelblue -font Meera -pointsize 50 -fill white -gravity center -bordercolor White -border 20x20 -draw "text 0,0 'ഉത്തരം'" image.png
magick -size 1040x1310 gradient:tomato-steelblue -font Meera -pointsize 50 -fill white -gravity center -bordercolor White -border 20x20 caption:'ഉത്തരം' image.png
magick -size 1040x1310 gradient:tomato-steelblue -font Meera -pointsize 50 -fill white -gravity center -bordercolor White -border 20x20 label:'ഉത്തരം' image.png
Version: ImageMagick 7.0.10-28 Q16 x86_64
Platform: Ubuntu
Previously I was using IM version 6 of 2017 build, now I upgraded to latest manually. Still convert --version shows 6 but magick --version and magick convert --version shows latest. I also tried above commands with magick convert.
Using ImageMagick 6.9.11.28 Q16 Mac OSX Sierra, the following label: command works just fine for me.
Perhaps your problem is the meera font you are using. I got mine from https://www.malayalamfont.com/download.php?id=867. Also check your version of freetype to be sure it is current. My version was 2.10.1
convert -size 100x -background white -font /Library/fonts/meera.ttf -fill black label:"ഉത്തരം" result.png
Also -annotate and -draw work:
convert -size 100x31 xc:white -gravity center -pointsize 28 -font /Library/fonts/meera.ttf -fill black -annotate +0+0 "ഉത്തരം" result.png
convert -size 100x31 xc:white -gravity center -pointsize 28 -font /Library/fonts/meera.ttf -fill black -draw "text 0,0 'ഉത്തരം'" result.png
I looked up how to type Option+0D09 Option+0D24 Option+0D4D Option+0D24 Option+0D30 Option+0D02 in my text editor. But what I get in the editor is not ഉത്തരം. It seems that pasting into this box changes what one sees.
What I see in my text editor is the same as what I get when I render it in ImageMagick. Are you sure your 3rd character set of code, Option+0D4D, is correct? I can verify that the utf codes are what I see in my text editor by looking them up using UnicodeChecker (for Mac). I note that these are UTF-16 characters.
convert -size 100x -background white -font /Library/fonts/Meera-Regular.ttf -fill black label:"ഉത്തരം" x1.png
Or saving what I type in my text editor to a file then doing:
convert -size 100x -background white -font /Library/fonts/Meera-Regular.ttf -fill black label:#hindi.txt x2.png
ADDITION:
Here are the glyphs for the UTF character codes you specified. These are exactly what I get from ImageMagick as above.
0D09:
0D24:
0D4D:
I am creating oldskool sprite images for an older gamedev software that loads 24-bit BMP only. The software detects the top left pixel color and makes it transparent on runtime.
I am trying to generate such BMP images with Imagemagick from transparent PNGs that I have, but I need the background to be lime #32cd32.
The following command in a batch file just makes a 24bit BMP file but the transparent areas appear black no matter what.
convert %1 -format bmp -type truecolor -background lime BMP3:"out.bmp"
Use the "-flatten" option:
convert $1 -background "#32cd32" -flatten BMP3:out.bmp
This composites the transparent image against the specified background color.
In ImageMagick, "lime" is saturated green (#00ff00). If you want #32cd32 use ' -background "#32cd32" '
Hard to estimate the issue without seeing the image, bit I would expect the alpha needs to be removed & replaced by the background color.
convert %1 -format bmp \
-type truecolor \
-alpha Remove \
-background lime \
BMP3:"out.bmp"
See "Alpha Remove" section.
The "-alpha Remove" method (added to IMv6.7.5) is designed to remove the transparency from an image, using the current "-background".
I want to create a contact sheet (thumbnails of images) which needs to have a logo at the top left corner, a set of images and notes appended at the end.
I am trying to achieve this by first converting the notes text to a pdf using:
convert -background white -fill black -font arial.ttf -pointsize 36 -size 1024x128 caption:'This is sample text' textPdf.pdf
Then, creating a contact sheet (thumbnails of images with title and caption) by using montage function which returns a pdf with multiple (6) pages. And,
Finally merging the above two pdfs with the logo as below:
convert logo.jpg montage.pdf textPdf.pdf -background none -append contactsheet.pdf
This however, appends all the pages (6) into a single paged pdf which renders the contact sheet useless as on printing this thumnails become too tiny to be identified.
Is there any other way by which I can add a logo at the top of each of the pages of the montage.pdf and append the textPdf.pdf at the end of the last page of the pdf?
Any help in this would be much appreciated.
If I understand correctly, you have this:
logo.jpg (1 image of unknown dimensions)
montage.pdf (a 6-page PDF with some arbitrary page size)
textPdf.pdf (a 1-page PDF with a very weird page size).
You want to create an output PDF of 7 pages named contactsheet.pdf, where
...the 1st page consists of the logo.jpg with the vertically appended 1st page from montage.pdf
...the 2nd page consists of the logo.jpg with the vertically appended 2nd page from montage.pdf
...the 3rd page consists of the logo.jpg with the vertically appended 3rd page from montage.pdf
...the 4th page consists of the logo.jpg with the vertically appended 4th page from montage.pdf
...the 5th page consists of the logo.jpg with the vertically appended 5th page from montage.pdf
...the 6th page consists of the logo.jpg with the vertically appended 6th page from montage.pdf
...the 7th page consist of the one weird pagesized textPdf.pdf.
This result can be achieved with the following command:
convert \
\( logo.jpg tiled.pdf[0] -background none -append \) \
\( logo.jpg tiled.pdf[1] -background none -append \) \
\( logo.jpg tiled.pdf[2] -background none -append \) \
\( logo.jpg tiled.pdf[3] -background none -append \) \
\( logo.jpg tiled.pdf[4] -background none -append \) \
\( logo.jpg tiled.pdf[5] -background none -append \) \
textPdf.pdf \
contactsheet.pdf
It makes use of the following advanced ImageMagick commandline features:
bracketing sub-commands inside \( ... \) (which each require a space before and after!) to create partial picture results;
using the 0-based [N]-index to address a particular image/frame/page of a multi-page image or PDF file.
I'm trying to use imagemagick to generate some images of Kannada text. The problem is that complex characters are being rendered separately (not together as they should be... imagine that "ku" should be one character, but it is rendered first as "k-" and then as "-u")
Concretely, ಗ್ರಾಮ ಕೋಡ್ gets rendered as this:
The command I am using is:
convert -background lightblue -fill blue -pointsize 48 -font '/Library/Fonts/Kannada Sangam MN.ttf' label:#Kannada_test.txt label_utf8.gif
On another program, TextEdit, the same font renders the text fine:
Any hints as to how I can get imagemagick to display these complex characters properly?
I’m afraid you can’t, because ImageMagick seems to be incapable of handling combining marks. That is, it cannot combine them with preceding characters to produce proper graphic presentation but render a spacing glyph for the mark.