예제 #1
0
    def testAddIcons_19_resize(self):
        files = ['16x16.png',
                 '16x15.png',
                 '16x17.png',
                 '15x16.png',
                 '17x16.png',
                 '17x17.png',
                 '15x15.png',
                 '8x8.png',
                 '8x16.png',
                 '16x8.png',
                 'first.png',
                 'first_vertical.png']

        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addIcons(None, fullPaths)

        icons = sorted(collection.getIcons(None))
        self.assertEqual(len(icons), 12)

        icons = {fname: os.path.join(self.tempDir1, fname) for fname in files}

        for fname in files:
            self.assertEqual(getImageSize(icons[fname]), (16, 16))
예제 #2
0
    def testWxThumbWidthJpeg (self):
        self.fname_in = "../test/images/first.jpg"
        self.fname_out = "../test/images/first_th.jpg"

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)

        self.thumbmaker = WxThumbmaker()
        newwidth = 250
        newheight = 182

        self.thumbmaker.thumbByWidth (self.fname_in, newwidth, self.fname_out)
        (width, height) = getImageSize (self.fname_out)

        self.assertEqual (width, newwidth)
        self.assertEqual (height, newheight)

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)
예제 #3
0
    def testWxThumbWidthTiff (self):
        self.fname_in = "../test/images/outwiker_1.1.0_02.tiff"
        self.fname_out = "../test/images/outwiker_1.1.0_02_th.png"

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)

        self.thumbmaker = WxThumbmaker()
        newwidth = 250
        newheight = 215

        self.thumbmaker.thumbByWidth (self.fname_in, newwidth, self.fname_out)
        (width, height) = getImageSize (self.fname_out)

        self.assertEqual (width, newwidth)
        self.assertEqual (height, newheight)

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)
예제 #4
0
    def testWxThumbHeightJpegPng (self):
        self.fname_in = "../test/images/first.jpg"
        self.fname_out = "../test/images/first_th.png"

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)

        self.thumbmaker = ThumbmakerWx()
        newheight = 180
        newwidth = 246

        self.thumbmaker.thumbByHeight (self.fname_in, newheight, self.fname_out)
        (width, height) = getImageSize (self.fname_out)

        self.assertEqual (width, newwidth)
        self.assertEqual (height, newheight)

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)
예제 #5
0
    def testWxThumbHeightJpeg(self):
        self.fname_in = "../test/images/first.jpg"
        self.fname_out = "../test/images/first_th.jpg"

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)

        self.thumbmaker = ThumbmakerPil()
        newheight = 180
        newwidth = 246

        self.thumbmaker.thumbByHeight(self.fname_in, newheight, self.fname_out)
        (width, height) = getImageSize(self.fname_out)

        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)
예제 #6
0
    def testWxThumbWidthTiff(self):
        self.fname_in = "../test/images/outwiker_1.1.0_02.tiff"
        self.fname_out = "../test/images/outwiker_1.1.0_02_th.png"

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)

        self.thumbmaker = ThumbmakerPil()
        newwidth = 250
        newheight = 215

        self.thumbmaker.thumbByWidth(self.fname_in, newwidth, self.fname_out)
        (width, height) = getImageSize(self.fname_out)

        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)
예제 #7
0
    def testAddIcons_19_resize(self):
        files = [
            u'16x16.png', u'16x15.png', u'16x17.png', u'15x16.png',
            u'17x16.png', u'17x17.png', u'15x15.png', u'8x8.png', u'8x16.png',
            u'16x8.png', u'first.png', u'first_vertical.png'
        ]

        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addIcons(None, fullPaths)

        icons = sorted(collection.getIcons(None))
        self.assertEqual(len(icons), 12)

        icons = {fname: os.path.join(self.tempDir1, fname) for fname in files}

        for fname in files:
            self.assertEqual(getImageSize(icons[fname]), (16, 16))
예제 #8
0
    def testThumbByHeightJpeg(self):
        images_dir = "../test/images"

        fname_in = "first.jpg"
        page = self.wikiroot["Страница 1"]

        Attachment(page).attach([os.path.join(images_dir, fname_in)])

        newwidth = 249
        newheight = 182

        thumb_fname = self.thumbmaker.createThumbByHeight(
            page, fname_in, newheight)
        thumb_path = os.path.join(page.path, thumb_fname)

        (width, height) = getImageSize(thumb_path)

        self.assertTrue(os.path.exists(thumb_path), thumb_path)
        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)
예제 #9
0
    def testThumbByWidthPng(self):
        images_dir = "../test/images"

        fname_in = "outwiker_1.1.0_02.png"
        page = self.wikiroot["Страница 1"]

        Attachment(page).attach([os.path.join(images_dir, fname_in)])

        newwidth = 250
        newheight = 215

        thumb_fname = self.thumbmaker.createThumbByWidth(
            page, fname_in, newwidth)
        thumb_path = os.path.join(page.path, thumb_fname)

        (width, height) = getImageSize(thumb_path)

        self.assertTrue(os.path.exists(thumb_path), thumb_path)
        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)
예제 #10
0
    def testWxThumbMaxSize_02_jpeg(self):
        self.fname_in = "../test/images/first_vertical.jpeg"
        self.fname_out = "../test/images/first_vertical_th.jpg"

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)

        self.thumbmaker = ThumbmakerPil()
        newsize = 250

        newwidth = 182
        newheight = 250

        self.thumbmaker.thumbByMaxSize(self.fname_in, newsize, self.fname_out)
        (width, height) = getImageSize(self.fname_out)

        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)
예제 #11
0
    def testWxThumbMaxSize_08_png (self):
        self.fname_in = "../test/images/8x16.png"
        self.fname_out = "../test/images/_thumb.png"

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)

        self.thumbmaker = ThumbmakerPil()
        newsize = 16

        newwidth = 8
        newheight = 16

        self.thumbmaker.thumbByMaxSize (self.fname_in, newsize, self.fname_out, larger=False)
        (width, height) = getImageSize (self.fname_out)

        self.assertEqual (width, newwidth)
        self.assertEqual (height, newheight)

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)
예제 #12
0
    def testWxThumbMaxSizeJpeg1(self):
        self.fname_in = "../test/images/first.jpg"
        self.fname_out = "../test/images/first_th.jpg"

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)

        self.thumbmaker = ThumbmakerWx()
        newsize = 250

        newwidth = 250
        newheight = 182

        self.thumbmaker.thumbByMaxSize(self.fname_in, newsize, self.fname_out)
        (width, height) = getImageSize(self.fname_out)

        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)
예제 #13
0
    def testWxThumbMaxSizeJpeg2 (self):
        self.fname_in = "../test/images/first_vertical.jpeg"
        self.fname_out = "../test/images/first_vertical_th.jpg"

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)

        self.thumbmaker = WxThumbmaker()
        newsize = 250

        newwidth = 182
        newheight = 250

        self.thumbmaker.thumbByMaxSize (self.fname_in, newsize, self.fname_out)
        (width, height) = getImageSize (self.fname_out)

        self.assertEqual (width, newwidth)
        self.assertEqual (height, newheight)

        if os.path.exists (self.fname_out):
            os.remove (self.fname_out)
예제 #14
0
    def testThumbByHeightJpeg(self):
        images_dir = "../test/images"

        fname_in = "first.jpg"
        page = self.wikiroot["Страница 1"]

        Attachment(page).attach([os.path.join(images_dir, fname_in)])

        newwidth = 249
        newheight = 182

        thumb_fname = self.thumbmaker.createThumbByHeight(page,
                                                          fname_in,
                                                          newheight)
        thumb_path = os.path.join(page.path, thumb_fname)

        (width, height) = getImageSize(thumb_path)

        self.assertTrue(os.path.exists(thumb_path), thumb_path)
        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)
예제 #15
0
    def testThumbByWidthPng(self):
        images_dir = "../test/images"

        fname_in = "outwiker_1.1.0_02.png"
        page = self.wikiroot["Страница 1"]

        Attachment(page).attach([os.path.join(images_dir, fname_in)])

        newwidth = 250
        newheight = 215

        thumb_fname = self.thumbmaker.createThumbByWidth(page,
                                                         fname_in,
                                                         newwidth)
        thumb_path = os.path.join(page.path, thumb_fname)

        (width, height) = getImageSize(thumb_path)

        self.assertTrue(os.path.exists(thumb_path), thumb_path)
        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)
예제 #16
0
    def testThumbByMaxSizeJpeg2(self):
        images_dir = "../test/images"

        fname_in = "first_vertical.jpeg"
        page = self.wikiroot["Страница 1"]

        Attachment(page).attach([os.path.join(images_dir, fname_in)])

        maxsize = 250

        newwidth = 182
        newheight = 250

        thumb_fname = self.thumbmaker.createThumbByMaxSize(
            page, fname_in, maxsize)
        thumb_path = os.path.join(page.path, thumb_fname)

        (width, height) = getImageSize(thumb_path)

        self.assertTrue(os.path.exists(thumb_path), thumb_path)
        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)
예제 #17
0
    def testThumbByMaxSizeJpeg2(self):
        images_dir = "../test/images"

        fname_in = "first_vertical.jpeg"
        page = self.wikiroot["Страница 1"]

        Attachment(page).attach([os.path.join(images_dir, fname_in)])

        maxsize = 250

        newwidth = 182
        newheight = 250

        thumb_fname = self.thumbmaker.createThumbByMaxSize(page,
                                                           fname_in,
                                                           maxsize)
        thumb_path = os.path.join(page.path, thumb_fname)

        (width, height) = getImageSize(thumb_path)

        self.assertTrue(os.path.exists(thumb_path), thumb_path)
        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)
예제 #18
0
    def testWxThumbMaxSize_08_png(self):
        self.fname_in = "../test/images/8x16.png"
        self.fname_out = "../test/images/_thumb.png"

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)

        self.thumbmaker = ThumbmakerPil()
        newsize = 16

        newwidth = 8
        newheight = 16

        self.thumbmaker.thumbByMaxSize(self.fname_in,
                                       newsize,
                                       self.fname_out,
                                       larger=False)
        (width, height) = getImageSize(self.fname_out)

        self.assertEqual(width, newwidth)
        self.assertEqual(height, newheight)

        if os.path.exists(self.fname_out):
            os.remove(self.fname_out)
예제 #19
0
 def __getMaxImageSize(self, fname):
     (width, height) = getImageSize(fname)
     return max(width, height)
예제 #20
0
 def __getMaxImageSize(self, fname):
     (width, height) = getImageSize(fname)
     return max(width, height)