#!/usr/bin/env python

from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color
import wandplus.image as wpi
from wandplus.textutil import calcSuitableFontsize, calcSuitableImagesize
import os
import unittest


tmpdir = '_tmp/'


def save(img, function, channel=False, ext='.png'):
    if channel:
        path = tmpdir + function.__name__ + "_ch" + ext
    else:
        path = tmpdir + function.__name__ + ext
    # print(path)
    img.save(filename=path)


class CheckImage(unittest.TestCase):

    @classmethod
    def setUpClass(self):
        os.mkdir(tmpdir)
        self.rose = Image(filename='rose:')
        self.grad = Image(filename='gradient:', width=400, height=400)
        self.logo = Image(filename='logo:')
        self.text = Image(filename='label:Confirm', width=200, height=60)
        self.text_a = Image(width=70, height=60)
        with Drawing() as draw:
            draw.font = 'Arial'
            draw.font_size = 50
            draw.gravity = 'center'
            draw.fill_color = Color('white')
            draw.stroke_color = Color('black')
            draw.text(0, 0, 'A')
            draw(self.text_a)

        self.rose.save(filename=tmpdir + 'rose.png')
        self.grad.save(filename=tmpdir + 'grad.png')
        self.logo.save(filename=tmpdir + 'logo.png')
        self.text.save(filename=tmpdir + 'text.png')
        self.text_a.save(filename=tmpdir + 'a.png')

    @classmethod
    def tearDownClass(self):
        self.rose.destroy()
        self.grad.destroy()
        self.logo.destroy()
        self.text.destroy()
        self.text_a.destroy()

    def test_adaptiveblur(self):
        f = wpi.adaptiveblur
        with self.rose.clone() as t:
            f(t, 5.0, 3.0)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 5.0, 3.0, channel='red')
            save(t, f, True)

    def test_adaptiveresize(self):
        f = wpi.adaptiveresize
        with self.rose.clone() as t:
            f(t, int(t.width*1.5), int(t.height*2.0))
            save(t, f)

    def test_adaptivesharpen(self):
        f = wpi.adaptivesharpen
        with self.rose.clone() as t:
            f(t, 5, 5)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 5, 5, channel='red')
            save(t, f, True)

    def test_adaptivethreshold(self):
        f = wpi.adaptivethreshold
        with self.logo.clone() as t:
            f(t, 20, 20, int(0.1*t.quantum_range))
            save(t, f)

    def test_addnoise(self):
        f = wpi.addnoise
        with self.grad.clone() as t:
            f(t, 'gaussian')
            save(t, f)
        with self.grad.clone() as t:
            f(t, 'gaussian', channel='red')
            save(t, f, True)

    def test_affinetransform(self):
        f = wpi.affinetransform
        with self.rose.clone() as t:
            with Drawing() as d:
                d.affine([2.0, 0.0, 0.0, 2.0, 0.0, 0.0])
                f(t, d)  # not work correctly (IM<6.9.9-36)
                save(t, f)

    def test_autogamma(self):
        f = wpi.autogamma
        with self.rose.clone() as t:
            f(t)
            save(t, f)
        with self.rose.clone() as t:
            f(t, channel='red')
            save(t, f, True)

    def test_autolevel(self):
        f = wpi.autolevel
        with self.rose.clone() as t:
            f(t)
            save(t, f)
        with self.rose.clone() as t:
            f(t, channel='red')
            save(t, f, True)

    def test_blackthreshold(self):
        f = wpi.blackthreshold
        with self.grad.clone() as t:
            f(t, Color('gray(50%)'))
            save(t, f)

    def test_blueshift(self):
        f = wpi.blueshift
        with self.logo.clone() as t:
            f(t, 0.5)
            save(t, f)

    def test_brightnesscontrast(self):
        f = wpi.brightnesscontrast
        with self.rose.clone() as t:
            f(t, -30, 0)
            save(t, f)
        with self.rose.clone() as t:
            f(t, -30, 0, channel='red')
            save(t, f, True)

    def test_blur(self):
        f = wpi.blur
        with self.rose.clone() as t:
            f(t, 0, 3)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 0, 3, channel='red')
            save(t, f, True)

    def test_charcoal(self):
        f = wpi.charcoal
        with self.rose.clone() as t:
            f(t, 5, 1)
            save(t, f)

    def test_chop(self):
        f = wpi.chop
        with self.grad.clone() as t:
            t.gravity = 'north_west'
            f(t, 0, 00, 200, 200)
            save(t, f)

    def test_clamp(self):
        f = wpi.clamp  # TODO: more useful code
        with self.rose.clone() as t:
            f(t)
            save(t, f)
        with self.rose.clone() as t:
            f(t, channel='red')
            save(t, f, True)

    def test_clip(self):  # NOTE: result is always FAILED.
        f = wpi.clip            # I don't have an image which has clipping path
        with self.rose.clone() as t:
            f(t)
            save(t, f)

    def test_clippath(self):  # NOTE: result is always FAILED.
        f = wpi.clippath
        with self.rose.clone() as t:
            f(t, '#1', True)
            save(t, f)

    def test_clut(self):
        f = wpi.clut
        with Image(filename='gradient:red-blue', width=1, height=100) as p:
            p.rotate(90)
            with self.grad.clone() as t:
                f(t, p)
                save(t, f)
            with self.grad.clone() as t:
                f(t, p, channel='green')
                save(t, f, True)

    def test_coalesce(self):  # TODO: input optimized .gif file.
        f = wpi.coalesce
        with Image() as t:
            with self.rose.clone() as p:
                for i in range(5):
                    wpi.blur(p, 0, 1)
                    wpi.add(t, p)
            with f(t) as p:
                save(p, f)

    def test_colordecisionlist(self):
        xml = """
        <ColorCorrectionCollection xmlns="urn:ASC:CDL:v1.2">
            <ColorCorrection id="cc03345">
                <SOPNode>
                    <Slope> 0.9 1.2 0.5 </Slope>
                    <Offset> 0.4 -0.5 0.6 </Offset>
                    <Power> 1.0 0.8 1.5 </Power>
                </SOPNode>
                <SATNode>
                    <Saturation> 0.85 </Saturation>
                </SATNode>
            </ColorCorrection>
        </ColorCorrectionCollection>
        """
        f = wpi.colordecisionlist
        with self.rose.clone() as t:
            f(t, xml)
            save(t, f)

    def test_colorize(self):
        f = wpi.colorize
        with self.grad.clone() as t:
            f(t, Color('red'), Color('gray(25%)'))
            save(t, f)

    def test_colormatrix(self):
        f = wpi.colormatrix
        with self.logo.clone() as t:
            kernel = [
                0.5, 0.0, 0.0, 0.0, 0.0,
                0.0, 1.5, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.5, 0.0, 0.0,
                0.0, 0.0, 0.0, 1.0, 0.0,
                0.0, 0.0, 0.0, 0.0, 1.0
            ]
            f(t, 5, 5, kernel)
            save(t, f)

    def test_combine(self):
        f = wpi.combine
        with Image() as t:
            w = 100
            h = 100
            black = Color('black')
            white = Color('white')
            with Image(width=w, height=w, background=black) as b:
                with Image(width=h, height=h, background=white) as w:
                    wpi.add(t, b)  # add image for red channel
                    wpi.add(t, b)  # add image for green channel
                    wpi.add(t, w)  # add image for blue channel
                    wpi.setfirstiterator(t)  # rewind the index pointer
                    channel = 1 + 2 + 4  # R + G + B
                    with f(t, channel) as q:
                        save(q, f)

    def test_comment(self):
        f = wpi.comment
        with self.grad.clone() as t:
            f(t, 'hello')
            save(t, f)

    def test_compare(self):
        f = wpi.compare
        with self.rose.clone() as t:
            with t.clone() as p:
                (c, d) = f(t, p, metric='absolute')
                save(c, f)
                c.destroy()
        with self.rose.clone() as t:
            with t.clone() as p:
                (c, d) = f(t, p, metric='absolute', channel='red')
                save(c, f, True)
                c.destroy()

    def test_comparelayer(self):
        f = wpi.comparelayer
        with Image() as t:
            with Image(width=50, height=50, background=Color('red')) as p:
                wpi.add(t, p)
                with Image(width=25, height=25, background=Color('green1')) as q:
                    for i in range(4):
                        with q.clone() as qq:
                            wpi.resetpage(qq, 5*(i+1), 5*(i+1))
                            wpi.add(t, qq)
            with f(t, 'compareany') as r:
                save(r, f, ext='.gif')

    def test_constitute(self):
        f = wpi.constitute
        with Image() as t:
            w = 2
            h = 2
            b = [0, 0, 0,
                 255, 255, 255,
                 255, 0, 0,
                 0, 255, 0]
            f(t, w, h, 'RGB', 'char', b)
            save(t, f)

    def test_contrast(self):
        f = wpi.contrast
        with self.rose.clone() as t:
            f(t, False)
            save(t, f)

    def test_convolve(self):
        f = wpi.convolve
        kernel = [1/16, 2/16, 1/16,
                  2/16, 4/16, 2/16,
                  1/16, 2/16, 1/16]
        with self.rose.clone() as t:
            f(t, 3, kernel)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 3, kernel, channel='red')
            save(t, f, True)

    def test_cyclecolormap(self):
        f = wpi.cyclecolormap
        with self.logo.clone() as t:
            f(t, 5)
            save(t, f)

    def test_cipher(self):
        f = wpi.encipher
        with self.rose.clone() as t:
            f(t, 'password')
            save(t, f)
            f = wpi.decipher
            f(t, 'password')
            save(t, f)

    def test_deskew(self):
        f = wpi.deskew
        with Image(width=80, height=40, background=Color('black')) as t:
            f(t, 0.5*t.quantum_range)  # TODO: find an skewed image as sample
            save(t, f)

    def test_despeckle(self):
        f = wpi.despeckle
        with self.rose.clone() as t:
            # TODO: add speckle noise
            f(t)
            save(t, f)

    def test_edge(self):
        f = wpi.edge
        with self.logo.clone() as t:
            f(t, 3)
            save(t, f)

    def test_emboss(self):
        f = wpi.emboss
        with self.logo.clone() as t:
            f(t, 0, 3)
            save(t, f)

    def test_enhance(self):
        f = wpi.enhance
        with Image(filename='plasma:', width=100, height=100) as t:
            f(t)
            save(t, f)

    def test_equalize(self):
        f = wpi.equalize
        with self.rose.clone() as t:
            f(t)
            save(t, f)
        with self.rose.clone() as t:
            f(t, channel='red')
            save(t, f, True)

    def test_exportpixels(self):
        w = 1
        h = 1
        channels = 'RGB'
        with Image(width=w, height=h, background=Color('red')) as t:
            r = wpi.exportpixels(t, 0, 0, w, h, channels, 'double')
            self.assertEqual(r[0], 1.0)
            self.assertEqual(r[1], 0.0)
            self.assertEqual(r[2], 0.0)

    def test_extent(self):
        f = wpi.extent
        with self.rose.clone() as t:
            t.gravity = 'center'
            t.background_color = Color('blue')
            f(t, -10, -10, t.width+20, t.height+20)
            save(t, f)

    def test_filterimage(self):
        f = wpi.filterimage
        kernel = [  # Sobel filter
            -1.0, 0.0, 1.0,
            -2.0, 0.0, 2.0,
            -1.0, 0.0, 1.0,
        ]
        with self.rose.clone() as t:
            f(t, 3, 3, kernel)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 3, 3, kernel, channel='red')
            save(t, f, True)

    def test_floodfillpaint(self):
        f = wpi.floodfillpaint
        with self.logo.clone() as t:
            f(t, Color('green'), 0.10*t.quantum_range, Color('white'), 0, 0)
            save(t, f)

    def test_fft(self):
        f = wpi.forwardfouriertransform  # require IM build option '--with-fftw'
        with self.logo.clone() as t:      # I couldn't build on Windows...
            f(t, True)
            save(t, f)  # includes two images(magnitude&phase)
            f = wpi.inversefouriertransform
            with t.sequence[0].clone() as mag:
                with t.sequence[1].clone() as phase:
                    wpi.blur(mag, 0, 0.5)  # as degradation
                    t2 = mag
                    f(t2, phase, True)
                    save(t2, f)

    def test_haldclut(self):
        f = wpi.haldclut  # TODO: more useful code
        with Image(filename='hald:12') as p:
            with self.rose.clone() as t:
                f(t, p)
                save(t, f)
            with self.rose.clone() as t:
                f(t, p, channel='red')
                save(t, f, True)

    def test_implode(self):
        f = wpi.implode
        with self.rose.clone() as t:
            f(t, 1.0)
            save(t, f)

    def test_importpixels(self):
        f = wpi.importpixels
        with Image(width=4, height=4, background=Color('red')) as t:
            w = 2
            h = 2
            b = [0, 0, 0,
                 255, 255, 255,
                 255, 0, 0,
                 0, 255, 0]
            f(t, 1, 1, w, h, 'RGB', 'char', b)
            save(t, f)

    def test_label(self):
        f = wpi.label
        with self.rose.clone() as t:
            f(t, 'hello')
            save(t, f)

    def test_localcontrast(self):
        f = wpi.localcontrast
        with self.logo.clone() as t:
            f(t, 5, 30)
            save(t, f)

    def test_magnify(self):
        f = wpi.magnify
        with self.rose.clone() as t:
            f(t)
            save(t, f)

    def test_minify(self):
        f = wpi.minify
        with self.rose.clone() as t:
            f(t)
            save(t, f)

    def test_montage(self):
        f = wpi.montage
        with self.rose.clone() as base:
            with Image() as dst:
                rows = 2
                columns = 3
                for i in range(rows * columns):
                    wpi.add(dst, base)

                tile = "{0}x{1}+0+0".format(columns, rows)
                thumb = "80x50+4+3"
                frame = "15x15+3+3"
                mode = "frame"
                with Drawing() as d:
                    with f(dst, d, tile, thumb, mode, frame) as result:
                        save(result, f)

    def test_morph(self):
        f = wpi.morph
        color = Color('white')
        with self.rose.clone() as t:
            with Image(width=t.width, height=t.height, background=color) as p:
                wpi.add(t, p)
                wpi.setfirstiterator(t)
                wpi.setdelay(t, 60)
                with f(t, 5) as q:
                    save(q, f, ext='.gif')

    def test_morphology(self):
        f = wpi.morphology
        with self.logo.clone() as t:
            f(t, 'dilate', 1, 'Diamond')
            save(t, f)
        with self.logo.clone() as t:
            f(t, 'dilate', 1, 'Diamond', channel='red')
            save(t, f, True)

    def test_motionblur(self):
        f = wpi.motionblur
        with self.logo.clone() as t:
            f(t, 30, 10, 45)
            save(t, f)
        with self.logo.clone() as t:
            f(t, 30, 10, 45, channel='red')
            save(t, f, True)

    def test_oilpaint(self):
        f = wpi.oilpaint
        with self.rose.clone() as t:
            f(t, 2.0)
            save(t, f)

    def test_opaquepaint(self):
        f = wpi.opaquepaint
        with self.logo.clone() as t:
            f(t, Color('red'), Color('blue'), 1.0, False)
            save(t, f)
        with self.logo.clone() as t:
            f(t, Color('red'), Color('blue'), 1.0, False, channel='blue')
            save(t, f, True)

    def test_orderedposterize(self):
        f = wpi.orderedposterize
        with self.grad.clone() as t:
            f(t, 'o4x4,3,3')
            save(t, f)
        with self.grad.clone() as t:
            f(t, 'o4x4,3,3', channel='red')
            save(t, f, True)

    def test_polaroid(self):
        f = wpi.polaroid
        with self.logo.clone() as t:
            with Drawing() as d:
                f(t, d, 1.0)
                save(t, f)

    def test_posterize(self):
        f = wpi.posterize
        with self.rose.clone() as t:
            f(t, 3, True)
            save(t, f)

    def test_raiseimage(self):
        f = wpi.raiseimage
        with self.rose.clone() as t:
            f(t, 10, 10, 10, 10, True)
            save(t, f)

    def test_randomthreshold(self):
        f = wpi.randomthreshold
        with self.text_a.clone() as t:
            rng = t.quantum_range
            f(t, int(rng * 0.05), int(rng * 0.95))
            save(t, f)
        with self.text_a.clone() as t:
            rng = t.quantum_range
            f(t, int(rng * 0.05), int(rng * 0.95), channel='red')
            save(t, f, True)

    def test_remap(self):
        f = wpi.remap
        with self.logo.clone() as t:
            with self.rose.clone() as p:
                f(t, p, 'nodither')
                save(t, f)

    def test_resample(self):
        f = wpi.resample
        with self.rose.clone() as t:
            dpi = 72 * 2
            f(t, dpi, dpi, 'lanczos', 1.0)
            save(t, f)

    def test_roll(self):
        f = wpi.roll
        with self.rose.clone() as t:
            f(t, 10, 10)
            save(t, f)

    def test_rotationalblur(self):
        f = wpi.rotationalblur
        with self.rose.clone() as t:
            f(t, 45)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 45, channel='red')
            save(t, f, True)

    def test_scale(self):
        f = wpi.scale
        with self.rose.clone() as t:
            f(t, t.width*2, t.height*2)
            save(t, f)

    def test_segment(self):
        f = wpi.segment
        with self.logo.clone() as t:
            f(t, 'rgb', False, 5, 20)
            save(t, f)

    def test_selectiveblur(self):
        f = wpi.selectiveblur
        with self.logo.clone() as t:
            f(t, 20, 20, 0.5*t.quantum_range)
            save(t, f)
        with self.logo.clone() as t:
            f(t, 20, 20, 0.5*t.quantum_range, channel='red')
            save(t, f, True)

    def test_separate_channel(self):
        f = wpi.separate_channel
        with self.rose.clone() as t:
            f(t, 'red')
            save(t, f)

    def test_sepiatone(self):
        f = wpi.sepiatone
        with self.rose.clone() as t:
            f(t, 0.5*t.quantum_range)
            save(t, f)

    def test_shade(self):
        f = wpi.shade
        with self.logo.clone() as t:
            f(t, True, 45, 135)
            save(t, f)

    def test_shadow(self):
        f = wpi.shadow
        with self.text.clone() as t:
            with self.text.clone() as p:
                p.negate()
                f(p, 100, 2, 10, 10)
                t.composite_channel('default_channels', p, 'overlay')
                save(t, f)

    def test_sharpen(self):
        f = wpi.sharpen
        with self.rose.clone() as t:
            f(t, 3, 3)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 3, 3, channel='red')
            save(t, f, True)

    def test_shave(self):
        f = wpi.shave
        with self.logo.clone() as t:
            f(t, 100, 100)
            save(t, f)

    def test_shear(self):
        f = wpi.shear
        with self.grad.clone() as t:
            f(t, Color('red'), 0, 10)
            save(t, f)

    def test_sigmoidalcontrast(self):
        f = wpi.sigmoidalcontrast
        with self.rose.clone() as t:
            f(t, True, 3, 3)
            save(t, f)
        with self.rose.clone() as t:
            f(t, True, 3, 3, channel='red')
            save(t, f, True)

    def test_sketch(self):
        f = wpi.sketch
        with self.logo.clone() as t:
            f(t, 10, 10, 45)
            save(t, f)

    def test_smush(self):
        f = wpi.smush

        def makeletter(letter, w, h):
            img = Image(width=w, height=h)
            with Drawing() as d:
                d.font = 'Arial'
                d.font_size = 24
                d.gravity = 'center'
                d.text(0, 0, letter)
                d(img)
            return img
        with Image() as t:
            with makeletter('A', 50, 30) as a:
                with makeletter('B', 50, 30) as b:
                    wpi.add(t, a)
                    wpi.add(t, b)
                    wpi.setfirstiterator(t)
            with f(t, False, -3) as p:
                save(p, f)

    def test_solarize(self):
        f = wpi.solarize
        with self.rose.clone() as t:
            f(t, 0.4*t.quantum_range)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 0.4*t.quantum_range, channel='red')
            save(t, f, True)

    def test_splice(self):
        f = wpi.splice
        with self.rose.clone() as t:
            t.gravity = 'center'
            f(t, t.width//2, t.height//2, 20, 20)
            save(t, f)

    def test_sparsecolor(self):
        f = wpi.sparsecolor
        with Image(width=100, height=100, background=Color('black')) as t:
            f(t, 'default_channels', 'bilinear',
              [0, 0,     1.0, 0.0, 0.0, 1.0,
               100, 100, 0.0, 1.0, 1.0, 1.0])
            save(t, f)

    def test_spread(self):
        f = wpi.spread
        with self.logo.clone() as t:
            f(t, 20)
            save(t, f)

    def test_statistic(self):
        f = wpi.statistic
        with self.rose.clone() as t:
            f(t, 'gradient', 4, 4)
            save(t, f)
        with self.rose.clone() as t:
            f(t, 'gradient', 4, 4, channel='red')
            save(t, f, True)

    def test_stegano(self):
        f = wpi.stegano
        with self.rose.clone() as t:
            w = 50
            h = 40
            offset = 15
            tmpfile = 'tmp.png'
            with Image(width=w, height=h, background=Color('white')) as p:
                with Drawing() as d:
                    d.gravity = 'center'
                    d.fill_color = Color('black')
                    d.text(0, 0, 'Watch\nthe\nPidgeon')
                    d(p)
                with f(t, p, offset) as q:
                    q.save(filename=tmpfile)
                try:
                    with Image() as q:
                        wpi.setsizeoffset(q, w, h, offset)
                        q.read(filename='stegano:' + tmpfile)
                        save(q, f)
                except Exception:
                    raise
                finally:
                    os.remove(tmpfile)

    def test_stereo(self):
        f = wpi.stereo
        with self.rose.clone() as t:
            with self.rose.clone() as p:
                p.negate()
                with f(t, p) as q:
                    save(q, f)

    def test_swirl(self):
        f = wpi.swirl
        with self.rose.clone() as t:
            f(t, 180)
            save(t, f)

    def test_texture(self):
        f = wpi.texture
        with Image(width=300, height=200) as t:
            with self.rose.clone() as p:
                with f(t, p) as q:
                    save(q, f)

    def test_thumbnail(self):
        f = wpi.thumbnail
        with self.logo.clone() as t:
            f(t, 100, 100)
            save(t, f)

    def test_tint(self):
        f = wpi.tint
        with self.rose.clone() as t:
            f(t, Color('rgb'), Color('gray(25%)'))
            save(t, f)

    def test_vignette(self):
        f = wpi.vignette
        with self.logo.clone() as t:
            wpi.minify(t)
            t.background_color = Color('black')
            f(t, 0, 10, 20, 20)
            save(t, f)

    def test_wave(self):
        f = wpi.wave
        with self.grad.clone() as t:
            f(t, 40, 200)
            save(t, f)

    def test_whitethreshold(self):
        f = wpi.whitethreshold
        with self.grad.clone() as t:
            f(t, Color('gray(50%)'))
            save(t, f)


class CheckTextUtil(unittest.TestCase):

    def test_imagesize(self):
        with Drawing() as d:
            text = 'check'
            d.font = 'Arial'
            d.font_size = 36
            size = calcSuitableImagesize(d, text)
            print('calcSuitableImagesize: ', size)
            self.assertTrue(size[0] > 0 and size[1] > 0)

    def test_fontsize(self):
        w = 100
        h = 100
        with Drawing() as d:
            text = 'check'
            d.font = 'Arial'
            fontsize = calcSuitableFontsize(d, text, width=w)
            print('calcSuitableImagesize[W]: ', fontsize)
            self.assertTrue(fontsize > 0)
            fontsize = calcSuitableFontsize(d, text, height=h)
            print('calcSuitableImagesize[H]: ', fontsize)
            self.assertTrue(fontsize > 0)


if __name__ == '__main__':
    unittest.main()

[((25402, 25417), 'unittest.main', 'unittest.main', ([], {}), '()\n', (25415, 25417), False, 'import unittest\n'), ((583, 599), 'os.mkdir', 'os.mkdir', (['tmpdir'], {}), '(tmpdir)\n', (591, 599), False, 'import os\n'), ((620, 643), 'wand.image.Image', 'Image', ([], {'filename': '"""rose:"""'}), "(filename='rose:')\n", (625, 643), False, 'from wand.image import Image\n'), ((664, 714), 'wand.image.Image', 'Image', ([], {'filename': '"""gradient:"""', 'width': '(400)', 'height': '(400)'}), "(filename='gradient:', width=400, height=400)\n", (669, 714), False, 'from wand.image import Image\n'), ((735, 758), 'wand.image.Image', 'Image', ([], {'filename': '"""logo:"""'}), "(filename='logo:')\n", (740, 758), False, 'from wand.image import Image\n'), ((779, 832), 'wand.image.Image', 'Image', ([], {'filename': '"""label:Confirm"""', 'width': '(200)', 'height': '(60)'}), "(filename='label:Confirm', width=200, height=60)\n", (784, 832), False, 'from wand.image import Image\n'), ((855, 881), 'wand.image.Image', 'Image', ([], {'width': '(70)', 'height': '(60)'}), '(width=70, height=60)\n', (860, 881), False, 'from wand.image import Image\n'), ((14981, 14995), 'wand.color.Color', 'Color', (['"""white"""'], {}), "('white')\n", (14986, 14995), False, 'from wand.color import Color\n'), ((895, 904), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (902, 904), False, 'from wand.drawing import Drawing\n'), ((1044, 1058), 'wand.color.Color', 'Color', (['"""white"""'], {}), "('white')\n", (1049, 1058), False, 'from wand.color import Color\n'), ((1091, 1105), 'wand.color.Color', 'Color', (['"""black"""'], {}), "('black')\n", (1096, 1105), False, 'from wand.color import Color\n'), ((5327, 5383), 'wand.image.Image', 'Image', ([], {'filename': '"""gradient:red-blue"""', 'width': '(1)', 'height': '(100)'}), "(filename='gradient:red-blue', width=1, height=100)\n", (5332, 5383), False, 'from wand.image import Image\n'), ((5726, 5733), 'wand.image.Image', 'Image', ([], {}), '()\n', (5731, 5733), False, 'from wand.image import Image\n'), ((7233, 7240), 'wand.image.Image', 'Image', ([], {}), '()\n', (7238, 7240), False, 'from wand.image import Image\n'), ((7307, 7321), 'wand.color.Color', 'Color', (['"""black"""'], {}), "('black')\n", (7312, 7321), False, 'from wand.color import Color\n'), ((7342, 7356), 'wand.color.Color', 'Color', (['"""white"""'], {}), "('white')\n", (7347, 7356), False, 'from wand.color import Color\n'), ((8533, 8540), 'wand.image.Image', 'Image', ([], {}), '()\n', (8538, 8540), False, 'from wand.image import Image\n'), ((9079, 9086), 'wand.image.Image', 'Image', ([], {}), '()\n', (9084, 9086), False, 'from wand.image import Image\n'), ((10898, 10946), 'wand.image.Image', 'Image', ([], {'filename': '"""plasma:"""', 'width': '(100)', 'height': '(100)'}), "(filename='plasma:', width=100, height=100)\n", (10903, 10946), False, 'from wand.image import Image\n'), ((11395, 11446), 'wandplus.image.exportpixels', 'wpi.exportpixels', (['t', '(0)', '(0)', 'w', 'h', 'channels', '"""double"""'], {}), "(t, 0, 0, w, h, channels, 'double')\n", (11411, 11446), True, 'import wandplus.image as wpi\n'), ((11721, 11734), 'wand.color.Color', 'Color', (['"""blue"""'], {}), "('blue')\n", (11726, 11734), False, 'from wand.color import Color\n'), ((13072, 13097), 'wand.image.Image', 'Image', ([], {'filename': '"""hald:12"""'}), "(filename='hald:12')\n", (13077, 13097), False, 'from wand.image import Image\n'), ((20563, 20587), 'wand.image.Image', 'Image', ([], {'width': 'w', 'height': 'h'}), '(width=w, height=h)\n', (20568, 20587), False, 'from wand.image import Image\n'), ((20820, 20827), 'wand.image.Image', 'Image', ([], {}), '()\n', (20825, 20827), False, 'from wand.image import Image\n'), ((23590, 23618), 'wand.image.Image', 'Image', ([], {'width': '(300)', 'height': '(200)'}), '(width=300, height=200)\n', (23595, 23618), False, 'from wand.image import Image\n'), ((24138, 24151), 'wandplus.image.minify', 'wpi.minify', (['t'], {}), '(t)\n', (24148, 24151), True, 'import wandplus.image as wpi\n'), ((24185, 24199), 'wand.color.Color', 'Color', (['"""black"""'], {}), "('black')\n", (24190, 24199), False, 'from wand.color import Color\n'), ((24638, 24647), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (24645, 24647), False, 'from wand.drawing import Drawing\n'), ((24758, 24788), 'wandplus.textutil.calcSuitableImagesize', 'calcSuitableImagesize', (['d', 'text'], {}), '(d, text)\n', (24779, 24788), False, 'from wandplus.textutil import calcSuitableFontsize, calcSuitableImagesize\n'), ((24972, 24981), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (24979, 24981), False, 'from wand.drawing import Drawing\n'), ((25067, 25105), 'wandplus.textutil.calcSuitableFontsize', 'calcSuitableFontsize', (['d', 'text'], {'width': 'w'}), '(d, text, width=w)\n', (25087, 25105), False, 'from wandplus.textutil import calcSuitableFontsize, calcSuitableImagesize\n'), ((25229, 25268), 'wandplus.textutil.calcSuitableFontsize', 'calcSuitableFontsize', (['d', 'text'], {'height': 'h'}), '(d, text, height=h)\n', (25249, 25268), False, 'from wandplus.textutil import calcSuitableFontsize, calcSuitableImagesize\n'), ((2879, 2888), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (2886, 2888), False, 'from wand.drawing import Drawing\n'), ((3624, 3642), 'wand.color.Color', 'Color', (['"""gray(50%)"""'], {}), "('gray(50%)')\n", (3629, 3642), False, 'from wand.color import Color\n'), ((6717, 6729), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (6722, 6729), False, 'from wand.color import Color\n'), ((6731, 6749), 'wand.color.Color', 'Color', (['"""gray(25%)"""'], {}), "('gray(25%)')\n", (6736, 6749), False, 'from wand.color import Color\n'), ((7374, 7416), 'wand.image.Image', 'Image', ([], {'width': 'w', 'height': 'w', 'background': 'black'}), '(width=w, height=w, background=black)\n', (7379, 7416), False, 'from wand.image import Image\n'), ((8638, 8651), 'wandplus.image.add', 'wpi.add', (['t', 'p'], {}), '(t, p)\n', (8645, 8651), True, 'import wandplus.image as wpi\n'), ((12324, 12338), 'wand.color.Color', 'Color', (['"""green"""'], {}), "('green')\n", (12329, 12338), False, 'from wand.color import Color\n'), ((12362, 12376), 'wand.color.Color', 'Color', (['"""white"""'], {}), "('white')\n", (12367, 12376), False, 'from wand.color import Color\n'), ((14448, 14455), 'wand.image.Image', 'Image', ([], {}), '()\n', (14453, 14455), False, 'from wand.image import Image\n'), ((15050, 15105), 'wand.image.Image', 'Image', ([], {'width': 't.width', 'height': 't.height', 'background': 'color'}), '(width=t.width, height=t.height, background=color)\n', (15055, 15105), False, 'from wand.image import Image\n'), ((15128, 15141), 'wandplus.image.add', 'wpi.add', (['t', 'p'], {}), '(t, p)\n', (15135, 15141), True, 'import wandplus.image as wpi\n'), ((15158, 15181), 'wandplus.image.setfirstiterator', 'wpi.setfirstiterator', (['t'], {}), '(t)\n', (15178, 15181), True, 'import wandplus.image as wpi\n'), ((15198, 15217), 'wandplus.image.setdelay', 'wpi.setdelay', (['t', '(60)'], {}), '(t, 60)\n', (15210, 15217), True, 'import wandplus.image as wpi\n'), ((16088, 16100), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (16093, 16100), False, 'from wand.color import Color\n'), ((16102, 16115), 'wand.color.Color', 'Color', (['"""blue"""'], {}), "('blue')\n", (16107, 16115), False, 'from wand.color import Color\n'), ((16206, 16218), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (16211, 16218), False, 'from wand.color import Color\n'), ((16220, 16233), 'wand.color.Color', 'Color', (['"""blue"""'], {}), "('blue')\n", (16225, 16233), False, 'from wand.color import Color\n'), ((16671, 16680), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (16678, 16680), False, 'from wand.drawing import Drawing\n'), ((20001, 20013), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (20006, 20013), False, 'from wand.color import Color\n'), ((20605, 20614), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (20612, 20614), False, 'from wand.drawing import Drawing\n'), ((23977, 23989), 'wand.color.Color', 'Color', (['"""rgb"""'], {}), "('rgb')\n", (23982, 23989), False, 'from wand.color import Color\n'), ((23991, 24009), 'wand.color.Color', 'Color', (['"""gray(25%)"""'], {}), "('gray(25%)')\n", (23996, 24009), False, 'from wand.color import Color\n'), ((24509, 24527), 'wand.color.Color', 'Color', (['"""gray(50%)"""'], {}), "('gray(50%)')\n", (24514, 24527), False, 'from wand.color import Color\n'), ((5836, 5853), 'wandplus.image.blur', 'wpi.blur', (['p', '(0)', '(1)'], {}), '(p, 0, 1)\n', (5844, 5853), True, 'import wandplus.image as wpi\n'), ((5874, 5887), 'wandplus.image.add', 'wpi.add', (['t', 'p'], {}), '(t, p)\n', (5881, 5887), True, 'import wandplus.image as wpi\n'), ((7444, 7486), 'wand.image.Image', 'Image', ([], {'width': 'h', 'height': 'h', 'background': 'white'}), '(width=h, height=h, background=white)\n', (7449, 7486), False, 'from wand.image import Image\n'), ((7513, 7526), 'wandplus.image.add', 'wpi.add', (['t', 'b'], {}), '(t, b)\n', (7520, 7526), True, 'import wandplus.image as wpi\n'), ((7576, 7589), 'wandplus.image.add', 'wpi.add', (['t', 'b'], {}), '(t, b)\n', (7583, 7589), True, 'import wandplus.image as wpi\n'), ((7641, 7654), 'wandplus.image.add', 'wpi.add', (['t', 'w'], {}), '(t, w)\n', (7648, 7654), True, 'import wandplus.image as wpi\n'), ((7705, 7728), 'wandplus.image.setfirstiterator', 'wpi.setfirstiterator', (['t'], {}), '(t)\n', (7725, 7728), True, 'import wandplus.image as wpi\n'), ((10276, 10290), 'wand.color.Color', 'Color', (['"""black"""'], {}), "('black')\n", (10281, 10290), False, 'from wand.color import Color\n'), ((11359, 11371), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (11364, 11371), False, 'from wand.color import Color\n'), ((12838, 12859), 'wandplus.image.blur', 'wpi.blur', (['mag', '(0)', '(0.5)'], {}), '(mag, 0, 0.5)\n', (12846, 12859), True, 'import wandplus.image as wpi\n'), ((13556, 13568), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (13561, 13568), False, 'from wand.color import Color\n'), ((14585, 14603), 'wandplus.image.add', 'wpi.add', (['dst', 'base'], {}), '(dst, base)\n', (14592, 14603), True, 'import wandplus.image as wpi\n'), ((14788, 14797), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (14795, 14797), False, 'from wand.drawing import Drawing\n'), ((20952, 20965), 'wandplus.image.add', 'wpi.add', (['t', 'a'], {}), '(t, a)\n', (20959, 20965), True, 'import wandplus.image as wpi\n'), ((20986, 20999), 'wandplus.image.add', 'wpi.add', (['t', 'b'], {}), '(t, b)\n', (20993, 20999), True, 'import wandplus.image as wpi\n'), ((21020, 21043), 'wandplus.image.setfirstiterator', 'wpi.setfirstiterator', (['t'], {}), '(t)\n', (21040, 21043), True, 'import wandplus.image as wpi\n'), ((21690, 21704), 'wand.color.Color', 'Color', (['"""black"""'], {}), "('black')\n", (21695, 21704), False, 'from wand.color import Color\n'), ((22555, 22564), 'wand.drawing.Drawing', 'Drawing', ([], {}), '()\n', (22562, 22564), False, 'from wand.drawing import Drawing\n'), ((22647, 22661), 'wand.color.Color', 'Color', (['"""black"""'], {}), "('black')\n", (22652, 22661), False, 'from wand.color import Color\n'), ((23152, 23170), 'os.remove', 'os.remove', (['tmpfile'], {}), '(tmpfile)\n', (23161, 23170), False, 'import os\n'), ((8602, 8614), 'wand.color.Color', 'Color', (['"""red"""'], {}), "('red')\n", (8607, 8614), False, 'from wand.color import Color\n'), ((22512, 22526), 'wand.color.Color', 'Color', (['"""white"""'], {}), "('white')\n", (22517, 22526), False, 'from wand.color import Color\n'), ((22877, 22884), 'wand.image.Image', 'Image', ([], {}), '()\n', (22882, 22884), False, 'from wand.image import Image\n'), ((22915, 22949), 'wandplus.image.setsizeoffset', 'wpi.setsizeoffset', (['q', 'w', 'h', 'offset'], {}), '(q, w, h, offset)\n', (22932, 22949), True, 'import wandplus.image as wpi\n'), ((8711, 8726), 'wand.color.Color', 'Color', (['"""green1"""'], {}), "('green1')\n", (8716, 8726), False, 'from wand.color import Color\n'), ((8847, 8890), 'wandplus.image.resetpage', 'wpi.resetpage', (['qq', '(5 * (i + 1))', '(5 * (i + 1))'], {}), '(qq, 5 * (i + 1), 5 * (i + 1))\n', (8860, 8890), True, 'import wandplus.image as wpi\n'), ((8911, 8925), 'wandplus.image.add', 'wpi.add', (['t', 'qq'], {}), '(t, qq)\n', (8918, 8925), True, 'import wandplus.image as wpi\n')]