update examples to py3
This commit is contained in:
parent
3cd880260f
commit
5afa726b8c
@ -18,7 +18,7 @@ in the API. It's also a useful source of examples.
|
|||||||
# Average a region of interest box on an image
|
# Average a region of interest box on an image
|
||||||
|
|
||||||
``` python
|
``` python
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import pyvips
|
import pyvips
|
||||||
@ -30,7 +30,7 @@ height = 64
|
|||||||
|
|
||||||
image = pyvips.Image.new_from_file(sys.argv[1])
|
image = pyvips.Image.new_from_file(sys.argv[1])
|
||||||
roi = image.crop(left, top, width, height)
|
roi = image.crop(left, top, width, height)
|
||||||
print 'average:', roi.avg()
|
print('average:', roi.avg())
|
||||||
```
|
```
|
||||||
|
|
||||||
# libvips and numpy
|
# libvips and numpy
|
||||||
@ -40,7 +40,7 @@ an area of memory. The memory array needs to be laid out band-interleaved,
|
|||||||
as a set of scanlines, with no padding between lines.
|
as a set of scanlines, with no padding between lines.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -50,7 +50,7 @@ from PIL import Image
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
print('usage: {0} input-filename output-filename'.format(sys.argv[0]))
|
print(f'usage: {sys.argv[0]} input-filename output-filename')
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# map vips formats to np dtypes
|
# map vips formats to np dtypes
|
||||||
@ -153,7 +153,7 @@ images, you'd need to do some more work to convert them all into the same
|
|||||||
colourspace before inserting them.
|
colourspace before inserting them.
|
||||||
|
|
||||||
``` python
|
``` python
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/python3
|
||||||
#file try255.py
|
#file try255.py
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
Loading…
Reference in New Issue
Block a user