(Obviously, 1000x2000 is excessive for small text files, and for longer ones at least the vertical dimension may need to be increased. The +repage at the very end prevents the output PNG being created with an image offset, which would otherwise cause GIMP to pop up a dialog on load asking whether it should apply the offset. Will render into a 1000x2000 box, then trim off the excess white space except for a 10-pixel border all the way around the text. annotate +15+15 -trim -bordercolor "#FFF" -border 10 +repage image.png The following command: convert -size 1000x2000 xc:white -font "FreeMono" -pointsize 12 -fill black \ I usually just pick excessive values, then take advantage of ImageMagick's -trim and -border to autocrop the result. Needing to guess the necessary dimensions of the output image can also be tedious. (There's no reason to increase the horizontal offset with larger font sizes, it has no relationship to the text dimensions.) I recommend going over by several pixels at least, so if you're using -pointsize 64 then you should pair that with something like -annotate +15+80. So if you don't shift the font down at least pointsize pixels, the top of the first line will be cut off. The second offset (vertical y-shift) must be at least equal to the point size of the font chosen (the argument to -pointsize), because ImageMagick will place the baseline of the font at the given offset. The first offset (horizontal x-shift) can be any positive integer, but needn't be greater than a few pixels. The arguments to -annotate (how far to shift the rendered text from the edge of the canvas) consist of horizontal and vertical pixel offsets (respectively). A list of the fonts available to any ImageMagick command can be obtained using the -list operator, so convert -list font will display all of the possible arguments to -font. The argument to -font can be any supported font name, if FreeMono isn't available (or simply isn't desired). Will output a rendered version of the given file contents, but without having to modify your "ascii.txt" file to contain the text 15x15 part of the -draw primitive. convert -size 360x360 xc:white -font "FreeMono" -pointsize 12 -fill black \ It's not as powerful as -draw, but for wholesale dumping of a text file's contents into an image it serves just fine. I find ImageMagick's -annotate operator to be a bit more convenient than the -draw method garethTheRed suggested, for the simple reason that it doesn't require modification of the input file. The font you choose should be a monospaced font, otherwise the text won't align. Single or double quotes will do, but make sure they're not used as part of your ascii-art as it will confuse matters. Also, make sure that the actual text to be converted is enclosed in quotes. With text 15,15 added as the first line of text (the 15,15 is a positional offset). Where ascii.txt is your ascii-art file:- text 15,15 ". Something similar to the following may help you:- convert -size 360x360 xc:white -font "FreeMono" -pointsize 12 -fill black -draw image.png
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |