Esempio n. 1
0
    def test(self):
        import pystacia
        from pystacia import image

        with catch_warnings(record=True) as w:
            simplefilter('always')

            self.assertTrue(
                image.blank(30, 30).is_same(pystacia.blank(30, 30)))

            self.assertTrue('blank' in w[-1].message.args[0])

            if lena_available():
                self.assertTrue(image.lena().is_same(pystacia.lena()))
                self.assertTrue('lena' in w[-1].message.args[0])

            tmpname = mkstemp()[1] + '.bmp'
            img = sample()
            img.write(tmpname)

            self.assertTrue(
                pystacia.read(tmpname).is_same(image.read(tmpname)))
            self.assertTrue('read' in w[-1].message.args[0])

            self.assertTrue(
                pystacia.read_blob(img.get_blob('bmp')).is_same(
                    image.read_blob(img.get_blob('bmp'))))

            self.assertTrue(
                pystacia.read_raw(**img.get_raw('rgb')).is_same(
                    image.read_raw(**img.get_raw('rgb'))))

            img.close()

            for symbol in [
                    'magick_logo', 'wizard', 'netscape', 'granite', 'rose'
            ]:
                self.assertTrue(
                    getattr(image,
                            symbol)().is_same(getattr(pystacia, symbol)()))
                self.assertTrue(symbol in w[-1].message.args[0])

            self.assertIsInstance(pystacia.Image(), image.Image)

            names = [
                'composites', 'types', 'filters', 'colorspaces',
                'compressions', 'axes'
            ]
            for name in names:
                self.assertEqual(
                    getattr(pystacia, name).x,
                    getattr(image, name).x)
                self.assertTrue(name in w[-1].message.args[0])
Esempio n. 2
0
def join():
    w, h = json.loads(r.get('image_dimensions'))
    image = pystacia.blank(w, h)
    for key in r.execute_command('LGETALL', 'completed_parts'):
        print "key:", key 
        data = pickle.loads(r.get(key))
#        f = open("./tmp/%s.png" % key, 'w')
#        f.write(data)
#        f.close()
        i, x1, x2, y1, y2 = key.split('_')
        print x1, x2
        t = pystacia.read_blob(data)
        image.overlay(t, int(x1), int(x2))
    image.write("foo.png")
Esempio n. 3
0
    def test(self):
        import pystacia
        from pystacia import image

        with catch_warnings(record=True) as w:
            simplefilter('always')

            self.assertTrue(image.blank(30, 30).
                            is_same(pystacia.blank(30, 30)))

            self.assertTrue('blank' in w[-1].message.args[0])

            if lena_available():
                self.assertTrue(image.lena().is_same(pystacia.lena()))
                self.assertTrue('lena' in w[-1].message.args[0])

            tmpname = mkstemp()[1] + '.bmp'
            img = sample()
            img.write(tmpname)

            self.assertTrue(pystacia.read(tmpname).
                            is_same(image.read(tmpname)))
            self.assertTrue('read' in w[-1].message.args[0])

            self.assertTrue(pystacia.read_blob(img.get_blob('bmp')).
                            is_same(image.read_blob(img.get_blob('bmp'))))

            self.assertTrue(pystacia.read_raw(**img.get_raw('rgb')).
                            is_same(image.read_raw(**img.get_raw('rgb'))))

            img.close()

            for symbol in ['magick_logo', 'wizard',
                           'netscape', 'granite', 'rose']:
                self.assertTrue(getattr(image, symbol)().
                                is_same(getattr(pystacia, symbol)()))
                self.assertTrue(symbol in w[-1].message.args[0])

            self.assertIsInstance(pystacia.Image(), image.Image)

            names = ['composites', 'types', 'filters', 'colorspaces',
                     'compressions', 'axes']
            for name in names:
                self.assertEqual(getattr(pystacia, name).x,
                                 getattr(image, name).x)
                self.assertTrue(name in w[-1].message.args[0])
Esempio n. 4
0
from os.path import join, dirname

from pystacia import blank, color, checkerboard

dest = join(dirname(__file__), '../_static/generated')

image = blank(100, 100)
image.checkerboard()
image.write(join(dest, 'transparent.jpg'))
image.close()

image = blank(100, 100, color.from_string('red'))
image.write(join(dest, 'red.jpg'))
image.close()

image = blank(100, 100, color.from_rgba(0, 1, 0, 0.5))
image.checkerboard()
image.write(join(dest, 'green.jpg'))
image.close()

image = checkerboard(200, 200)
image.write(join(dest, 'checkerboard.png'))
image.close()
Esempio n. 5
0
from os.path import join, dirname

from pystacia import blank, color, checkerboard

dest = join(dirname(__file__), "../_static/generated")

image = blank(100, 100)
image.checkerboard()
image.write(join(dest, "transparent.jpg"))
image.close()

image = blank(100, 100, color.from_string("red"))
image.write(join(dest, "red.jpg"))
image.close()

image = blank(100, 100, color.from_rgba(0, 1, 0, 0.5))
image.checkerboard()
image.write(join(dest, "green.jpg"))
image.close()

image = checkerboard(200, 200)
image.write(join(dest, "checkerboard.png"))
image.close()