Quantcast

Make a grid using ImageMagick

I needed a jpeg with gridlines on it. Here is a python script that will generate the arguments to ImageMagick to create a grid:

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/python
 
cmd = 'convert -size 1000x1000 xc:white -strokewidth 1 '
 
for i in range(0, 999, 100):
  cmd += "-draw 'line "+str(i)+",0 "+str(i)+",999' "
 
for i in range(0, 999, 100):
  cmd += "-draw 'line 0,"+str(i)+" 999,"+str(i)+"' "
 
cmd += "grid.jpg"
 
print cmd

No comments yet. Be the first.

Leave a reply