Save a python script like this:
#!/usr/bin/python
from PIL import Image, ImageFont, ImageDraw
import sys
im = Image.new('CMYK', (1000,1000), (0, 0, 0, 255))
f = ImageFont.load_default()
d = ImageDraw.Draw(im)
d.text((500, 500), sys.argv[1], font = f, fill = (0, 0, 0, 0))
del d
im.save(sys.argv[2])
Dependencies are python and the python imaging library. Then you can create your images with this command:
python cmyktext.py "Josh test" Jtest.pdf
Don't forget that cmyk is subtractive, so (0,0,0,0) is actually white. It is of course also possible to use any font you like, as documented here.
I found an inelegant way to do that using orion's proposal. Assuming $svg_file_name
is a variable containing file path to an SVG image.
First we need image width and height
width=$(exiftool -ImageWidth $svg_file_name | sed "s/.*: //;s/pt//g")
height=$(exiftool -ImageHeight $svg_file_name | sed "s/.*: //;s/pt//g")
PlantUML produces the diagram as a single group (tag <g>
), let's place rectangle of canvas size over that group
sed -i "s|</g>|</g><polygon fill=\"#FFFFFF\" points=\"0,0,0,$height,$width,$height,$width,0\" style=\"stroke: #000000; stroke-width: 1.0;\"/>|" $svg_file_name
Now open image with inkscape, select all and clip the group with the rectangle
inkscape --verb=EditSelectAll --verb=ObjectSetClipPath --verb=FileSave --verb=FileClose $svg_file_name
With the latest Inkscape one needs to quit Inkscape instead of closing the file
inkscape --verb=EditSelectAll --verb=ObjectSetClipPath --verb=FileSave --verb=FileQuit $svg_file_name
Best Answer
I'd use
convert
ormogrify
from the ImageMagick suite.convert
takes a separate output filename; creating a separate file.mogrify
doesn't take a separate output filename; modifying the file in place