2011-06-17 15:50:14 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import logging
|
2011-06-18 14:34:52 +02:00
|
|
|
import gc
|
2011-06-17 15:50:14 +02:00
|
|
|
|
2011-06-18 18:47:56 +02:00
|
|
|
import gobject
|
|
|
|
|
2011-12-23 16:20:54 +01:00
|
|
|
import vipsobject
|
2011-06-17 15:50:14 +02:00
|
|
|
import vipsimage
|
|
|
|
|
|
|
|
logging.basicConfig(level = logging.DEBUG)
|
|
|
|
|
2011-06-18 18:47:56 +02:00
|
|
|
# should be able to find vipsimage, hopefully
|
|
|
|
print gobject.type_from_name('VipsImage')
|
|
|
|
|
2011-06-18 14:34:52 +02:00
|
|
|
# test unref
|
|
|
|
for i in range (1,10):
|
|
|
|
a = vipsimage.VipsImage('/home/john/pics/healthygirl.jpg')
|
|
|
|
|
2011-06-17 15:50:14 +02:00
|
|
|
# should work
|
|
|
|
a = vipsimage.VipsImage('/home/john/pics/healthygirl.jpg')
|
2011-06-18 14:34:52 +02:00
|
|
|
print 'width =', a.width()
|
|
|
|
print 'height =', a.height()
|
|
|
|
print 'bands =', a.bands()
|
2011-12-23 16:20:54 +01:00
|
|
|
print 'format = %d - %s' % (a.format(),
|
|
|
|
vipsimage.VipsBandFormat.name(a.format()))
|
|
|
|
print 'coding = %d - %s' % (a.coding(),
|
|
|
|
vipsimage.VipsCoding.name(a.coding()))
|
|
|
|
print 'interpretation = %d - %s' % (a.interpretation(),
|
|
|
|
vipsimage.VipsInterpretation.name(a.interpretation()))
|
2011-06-18 14:34:52 +02:00
|
|
|
print 'xres =', a.xres()
|
|
|
|
print 'yres =', a.yres()
|
|
|
|
print 'xoffset =', a.xoffset()
|
|
|
|
print 'yoffset =', a.yoffset()
|
2011-06-17 15:50:14 +02:00
|
|
|
|
|
|
|
# should raise an error
|
2011-12-23 16:20:54 +01:00
|
|
|
try:
|
|
|
|
a = vipsimage.VipsImage('banana')
|
|
|
|
except vipsobject.VipsError, e:
|
|
|
|
print 'caught VipsError'
|
|
|
|
print '\tmessage =', e.message
|
|
|
|
print '\tdetail =', e.detail
|
2011-06-18 18:47:56 +02:00
|
|
|
|
|
|
|
# try calling a vips8 method
|
|
|
|
a = vipsimage.VipsImage('/home/john/pics/healthygirl.jpg')
|
|
|
|
b = vipsimage.VipsImage('/home/john/pics/babe.jpg')
|
|
|
|
c = a.add(b)
|
2011-06-18 14:34:52 +02:00
|
|
|
|
2011-12-23 16:20:54 +01:00
|
|
|
print 'c = ', c
|
|
|
|
|
|
|
|
c.write('/home/john/pics/x.v')
|
|
|
|
|
2011-06-18 14:34:52 +02:00
|
|
|
print 'starting shutdown ...'
|
|
|
|
del a
|
2011-06-18 18:47:56 +02:00
|
|
|
del b
|
|
|
|
del c
|
2011-06-18 14:34:52 +02:00
|
|
|
# sometimes have to do several GCs to get them all, not sure why
|
|
|
|
for i in range(10):
|
|
|
|
gc.collect ()
|
|
|
|
print 'shutdown!'
|
|
|
|
|