def test_get_units(): w = Image() assert None == w.units api.MagickNewImage(w._wand, 100, 100, api.NewPixelWand()) assert None == w.units api.MagickSetImageUnits(w._wand, api.PixelsPerInchResolution) assert PIXELS_PER_INCH == w.units
def test_get_format(): w = Image() assert None == w.format api.MagickNewImage(w._wand, 100, 100, api.NewPixelWand()) assert None == w.format api.MagickSetImageFormat(w._wand, 'PNG') assert 'PNG' == w.format
def test_constructor_with_file(): w = Image(StringIO(GIF)) assert 'GIF' == w.format assert (1,1) == w.size size = api.size_t() b = api.MagickGetImageBlob(w._wand, size) assert GIF == ''.join([chr(b[i]) for i in range(0, size.value + 1)])
def convert(source_fh, source_type, dest_type, dest_size): """somewhat like convert(1)""" i = Image(source_fh, source_type) if not i.select(dest_size): print "bad size" i.alpha(True) i.scale(dest_size) i.alpha(True) result = i.dump(dest_type) return result
from pythonmagickwand.image import Image i = Image('./assets/064fa8ad-4b88-452f-a110-68f1250be0c3_texture.jp2') i.format = 'PNG' i.flip() i.save('flip.png')
def test_get_colorspace(): w = Image() assert None == w.colorspace w = setup() api.MagickSetImageColorspace(w._wand, CMYK_COLORSPACE) assert CMYK_COLORSPACE == w.colorspace
def setup(): i = Image() api.MagickNewImage(i._wand, 100, 100, api.NewPixelWand()) return i
def test_constructor_with_eps_file(): w = Image(StringIO(EPS)) assert 'EPS' == w.format size = api.size_t() b = api.MagickGetImageBlob(w._wand, size) assert EPS == ''.join([chr(b[i]) for i in range(0, size.value + 1)])