add text problem
-
- Posts: 38
- Joined: 2010-12-14T03:56:10-07:00
- Authentication code: 8675308
add text problem
i am having problem in creating text multiple words. like when i add 'abc' it fine but when i add 'abc xyz', in this case it only takes 'abc'.
i use this below code for doing this
convert -background none -fill '#000000' -font images/ttf_files/ARIALNI.TTF -pointsize 15 label:Ratnesh Soni \
images/textLarge/Ratneshd0292be4f764354efa2ac838c0051215.png
i use this below code for doing this
convert -background none -fill '#000000' -font images/ttf_files/ARIALNI.TTF -pointsize 15 label:Ratnesh Soni \
images/textLarge/Ratneshd0292be4f764354efa2ac838c0051215.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: add text problem
You need to use quotes around your text, Otherwise the shell parser makes the two words two separate options (space separated). IM then thinks the second 'known' option is a filename and fails to find any such file!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 38
- Joined: 2010-12-14T03:56:10-07:00
- Authentication code: 8675308
Re: add text problem
thanx it works fine but one more thing in case when i add stroke to text have same problem which i have earlier
the command i use is below
convert -size 200x500 xc:none -font images/ttf_files/ARIALNI.TTF -pointsize 15 -fill '#000000' \
-stroke '#3399CC' -strokewidth 2 -draw 'text 30,60 'Ratnesh Soni'' \
-stroke none -draw 'text 30,60 'Ratnesh Soni'' \
images/textLarge/Ratnesh Sonid0292be4f764354efa2ac838c0051215.png
the command i use is below
convert -size 200x500 xc:none -font images/ttf_files/ARIALNI.TTF -pointsize 15 -fill '#000000' \
-stroke '#3399CC' -strokewidth 2 -draw 'text 30,60 'Ratnesh Soni'' \
-stroke none -draw 'text 30,60 'Ratnesh Soni'' \
images/textLarge/Ratnesh Sonid0292be4f764354efa2ac838c0051215.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: add text problem
If you use -draw you need to use two layers of quoting. BOTH layers much also end.
The first layer is for the command line shell so the quoted string is kept together. The second layer is given to IM to mark the actaul string to be "rendered" onto the image.
This is easiest when the two layers use DIFFERENT quotes. As such you need to use
In this case the shell parses this as two arguments. -draw and the string text 30,60 'Ratnesh Soni' with the outside quotes removed.
You can however use the same quote if you tell the shell that the internal quotes do not end the argument, but is just a quote character which is part of the argument. (double is easier for this). For example The shell passes the string argument as text 30,60 "Ratnesh Soni" Note that not only was the outside quotes removed but the backslashes inside the sting (protecting the inside quotes) are also removed. This is normal double quote shell handling.
Read about Shell Quoting (google for it) for more information.
For more details of using quotes with -draw see To Quote or Backslash?
The easier was is to use -annotate instead of draw as it only needs ONE layer of quoting (for the shell only)
See http://www.imagemagick.org/Usage/text/#annotateAnnotate - Text Drawing Operator
The first layer is for the command line shell so the quoted string is kept together. The second layer is given to IM to mark the actaul string to be "rendered" onto the image.
This is easiest when the two layers use DIFFERENT quotes. As such you need to use
Code: Select all
-draw "text 30,60 'Ratnesh Soni' "
You can however use the same quote if you tell the shell that the internal quotes do not end the argument, but is just a quote character which is part of the argument. (double is easier for this). For example
Code: Select all
-draw "text 30,60 \"Ratnesh Soni\" "
Read about Shell Quoting (google for it) for more information.
For more details of using quotes with -draw see To Quote or Backslash?
The easier was is to use -annotate instead of draw as it only needs ONE layer of quoting (for the shell only)
See http://www.imagemagick.org/Usage/text/#annotateAnnotate - Text Drawing Operator
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 38
- Joined: 2010-12-14T03:56:10-07:00
- Authentication code: 8675308
Re: add text problem
it not take text in newline. i am using textarea to wirte text.
plz help me
plz help me
-
- Posts: 38
- Joined: 2010-12-14T03:56:10-07:00
- Authentication code: 8675308
Re: add text problem
but the main problem with is that i am using textarea or textbox write text and having button when user click on that it generate the text image.
I cant add \n in that help me
I cant add \n in that help me
Re: add text problem
This is not a php forum but a couple of suggestions for you to look into:
1/ Use caption as Fred suggests.
2/ Get the users to add <br> or a character e.g. | where they want an end of line and convert that to \\n
3/ Use Wordwrap and convert the character which wordwrap uses to \\n
1/ Use caption as Fred suggests.
Code: Select all
<?php
exec("convert -size 230x130 -background lightblue -font verdana.ttf -pointsize 25 \\
-gravity NorthWest caption:\"The quick red fox jumped over the lazy brown dog.\" \\
-flatten caption1.jpg");
?>
3/ Use Wordwrap and convert the character which wordwrap uses to \\n
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: add text problem
caption: will word wrap appropriately so that line feeds, carriage returns, new line characters are not needed. So take the text box data, strip any returns if necessary and just feed to caption:
Read http://www.imagemagick.org/Usage/text/#caption
Read http://www.imagemagick.org/Usage/text/#caption