pymagery — python imagery
1.4.0 documentation / resize plugin
The resize plugin performs arbitrary shrinking and expanding of images. It is not the same as the canvasresize plugin. When an image is resized the pixel values change and are interpolated to the new size.
The plugin prototype is:
def resize(width=None, height=None, stretch=None, method='bilinear')
Either the width & height must be supplied or the stretch factor. If the stretch factor is supplied then the existing width & height are scaled by the value, thus 1.0 would yield no change. Currently, the only implemented interpolation method is "bilinear".
The following example scales the image up by 50% (or a factor of 1.5):
import pymagery
i = pymagery.image('foo.ppm')
i.resize(resize=1.5)
i.save('foo-bigger.ppm')
| Original (130x75) | Scaled (195x112) |
|---|---|
![]() |
![]() |
The following example scales the image up by 50% (or a factor of 1.5) and then chops off a 10 pixel border:
import pymagery
i = pymagery.image('foo.ppm')
i.RESIZE(resize=1.5).border(-10)
i.save('foo-bigger-border.ppm')
| Original (130x75) | Scaled/Border (175x92) |
|---|---|
![]() |
![]() |
Change Log
- 1.3.0 — added
Copyright © 2008 Colin ML Burnett, released under GPLv2


