2007-08-29 18:23:50 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# just need this for leaktesting
|
|
|
|
import gc
|
|
|
|
|
|
|
|
from vipsCC import *
|
|
|
|
|
|
|
|
if len (sys.argv) != 3:
|
|
|
|
print 'usage:', sys.argv[0], 'inputimage outputimage'
|
|
|
|
print '\tcalculate photographic negative of inputimage'
|
|
|
|
sys.exit (1)
|
|
|
|
|
|
|
|
try:
|
|
|
|
a = VImage.VImage (sys.argv[1])
|
|
|
|
b = a.invert ()
|
|
|
|
c = b.lin ([1,2,3],[4,5,6])
|
2008-07-29 13:30:48 +02:00
|
|
|
m = VMask.VIMask (3, 3, 1, 0,
|
|
|
|
[-1, -1, -1,
|
|
|
|
-1, 8, -1,
|
|
|
|
-1, -1, -1])
|
|
|
|
d = a.conv (m)
|
|
|
|
d.write (sys.argv[2])
|
2007-08-29 18:23:50 +02:00
|
|
|
except VError.VError, e:
|
|
|
|
e.perror (sys.argv[0])
|
|
|
|
|
|
|
|
# we can get properties of VImage too
|
|
|
|
print 'inputimage is', a.Xsize (), 'pixels across'
|
|
|
|
|
|
|
|
print 'starting shutdown ...'
|
|
|
|
del b
|
|
|
|
del a
|
|
|
|
del c
|
2008-07-29 13:30:48 +02:00
|
|
|
del d
|
|
|
|
del m
|
2007-08-29 18:23:50 +02:00
|
|
|
# sometimes have to do several GCs to get them all, not sure why
|
|
|
|
for i in range(10):
|
|
|
|
gc.collect ()
|
|
|
|
print 'shutdown!'
|
|
|
|
|
|
|
|
print 'leaked IMAGEs:'
|
|
|
|
VImage.im__print_all ()
|
|
|
|
print 'done ... hopefully you saw no leaks'
|