Пример #1
0
    def testwxThumbRaises(self):
        self.fname_in = "../test/images/first_vertical_error.jpeg"
        self.fname_out = "../test/images/first_vertical_error_th.jpg"
        newsize = 250

        self.thumbmaker = ThumbmakerPil()

        self.assertRaises(ThumbException, self.thumbmaker.thumbByWidth,
                          self.fname_in, newsize, self.fname_out)
        self.assertRaises(ThumbException, self.thumbmaker.thumbByHeight,
                          self.fname_in, newsize, self.fname_out)
        self.assertRaises(ThumbException, self.thumbmaker.thumbByMaxSize,
                          self.fname_in, newsize, self.fname_out)
Пример #2
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)
Пример #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 = 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)
Пример #4
0
    def testWxThumbWidthJpeg(self):
        self.fname_in = "testdata/images/first.jpg"
        self.fname_out = "testdata/images/first_th.jpg"

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

        self.thumbmaker = ThumbmakerPil()
        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)
Пример #5
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)
Пример #6
0
    def testWxThumbMaxSize_08_png(self):
        self.fname_in = "testdata/images/8x16.png"
        self.fname_out = "testdata/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)
Пример #7
0
    def testWxThumbMaxSize_06_png(self):
        self.fname_in = "../test/images/16x8.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 = 16
        newheight = 8

        self.thumbmaker.thumbByMaxSize(self.fname_in,
                                       newsize,
                                       self.fname_out,
                                       larger=True)
        (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)
Пример #8
0
    def __init__(self):
        # Имя файла превьюшки: th_width_200_fname
        # Имя файла превьюшки: th_height_100_fname
        self.thumbsTemplate = "th_%s_%d_%s"

        self.thumbmaker = ThumbmakerPil()