예제 #1
0
    def test_convert_jpg_to_png(self):
        file_path_fixture = self.get_fixture_file_path("thumbnails/th04.jpg")
        file_name = "th04.jpg"
        file_path = os.path.join(TEST_FOLDER, file_name)
        fs.copyfile(file_path_fixture, file_path)
        im = Image.open(file_path)

        thumbnail.convert_jpg_to_png(file_path)
        result_path = os.path.join(TEST_FOLDER, "th04.png")
        im = Image.open(result_path)
        self.assertEqual(len(im.info.keys()), 0)
        self.assertTrue(os.path.exists(result_path))
예제 #2
0
    def test_turn_into_thumbnail(self):
        file_path_fixture = self.get_fixture_file_path("thumbnails/th01.png")
        full_path = thumbnail.get_file_path("shots", "instance-id")
        thumbnail.create_folder("shots")
        fs.copyfile(file_path_fixture, full_path)

        thumbnail.turn_into_thumbnail(full_path)
        im = Image.open(full_path)
        (width, height) = im.size
        self.assertEqual(width, 180)
        self.assertEqual(height, 101)

        thumbnail.turn_into_thumbnail(full_path, thumbnail.RECTANGLE_SIZE)
        im = Image.open(full_path)
        (width, height) = im.size
        self.assertEqual(width, 150)
        self.assertEqual(height, 100)
예제 #3
0
    def test_turn_into_thumbnail(self):
        file_path_fixture = self.get_fixture_file_path("thumbnails/th01.png")
        full_path = os.path.join(TEST_FOLDER,
                                 thumbnail.get_file_name("instance-id"))
        fs.copyfile(file_path_fixture, full_path)

        thumbnail.turn_into_thumbnail(full_path)
        im = Image.open(full_path)
        (width, height) = im.size
        self.assertEqual(width, 180)
        self.assertEqual(height, 101)

        thumbnail.turn_into_thumbnail(full_path, thumbnail.RECTANGLE_SIZE)
        im = Image.open(full_path)
        (width, height) = im.size
        self.assertEqual(width, 150)
        self.assertEqual(height, 100)
예제 #4
0
    def test_generate_preview_variants(self):
        preview_id = "123413-12312"
        file_path_fixture = self.get_fixture_file_path("thumbnails/th01.png")
        file_name = thumbnail.get_file_name(preview_id)
        original_path = os.path.join(TEST_FOLDER, file_name)
        fs.copyfile(file_path_fixture, original_path)
        thumbnail.generate_preview_variants(original_path, preview_id)

        file_path = os.path.join(TEST_FOLDER, "previews-%s.png" % preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.PREVIEW_SIZE)

        file_path = os.path.join(TEST_FOLDER, "thumbnails-%s.png" % preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.RECTANGLE_SIZE)

        file_path = os.path.join(TEST_FOLDER,
                                 "thumbnails-square-%s.png" % preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.SQUARE_SIZE)
예제 #5
0
    def test_generate_preview_variants(self):
        preview_id = "123413-12312"
        file_path_fixture = self.get_fixture_file_path("thumbnails/th01.png")
        file_name = thumbnail.get_file_name(preview_id)
        folder_path = thumbnail.get_preview_folder_name(
            "originals", preview_id)
        fs.mkdir_p(folder_path)
        fs.copyfile(file_path_fixture, os.path.join(folder_path, file_name))
        thumbnail.generate_preview_variants(preview_id)

        file_path = thumbnail.get_preview_file_path("previews", preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.PREVIEW_SIZE)

        folder_path = thumbnail.get_preview_folder_name(
            "thumbnails", preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.RECTANGLE_SIZE)

        folder_path = thumbnail.get_preview_folder_name(
            "thumbnails-square", preview_id)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(Image.open(file_path).size, thumbnail.SQUARE_SIZE)