def test_cropname(self):
        transmog = Transmogrify(
            utils.generate_url(self.horiz_img, '_c0-510-300-810'))
        transmog.cropname = "cropped"
        _, proc_name = os.path.split(transmog.get_processed_filename())

        self.assertEqual(proc_name, self.cropname_img)
    def test_border(self):
        transmog = Transmogrify(utils.generate_url(self.square_img, '_b3-f00'))
        transmog.save()
        transmog = Transmogrify(utils.generate_url(self.vert_img, '_b3-f00'))
        transmog.save()
        transmog = Transmogrify(utils.generate_url(self.horiz_img, '_b3-f00'))
        transmog.save()

        security_hash = utils.generate_url(self.horiz_img, '_b3-f00').split('?')[1]
        self.assertEqual(security_hash, transmog.get_security_hash())
Beispiel #3
0
def test_get_cached_files():
    import os
    from transmogrify import settings
    from transmogrify.core import Transmogrify
    testdata = os.path.abspath(settings.BASE_PATH)
    t = Transmogrify('/horiz_img_r300x300.jpg?debug')
    t.save()
    result = utils.get_cached_files('/horiz_img.jpg', document_root=testdata)
    filenames = [x.replace(testdata, '') for x in result]
    assert '/horiz_img_r300x300.jpg' in filenames
 def test_letterbox(self):
     transmog = Transmogrify(utils.generate_url(self.square_img, '_l300x300-888'))
     transmog.save()
     transmog = Transmogrify(utils.generate_url(self.vert_img, '_l300x300-888'))
     transmog.save()
     transmog = Transmogrify(utils.generate_url(self.horiz_img, '_l300x300-888'))
     transmog.save()
    def test_cropname(self):
        transmog = Transmogrify(utils.generate_url(self.horiz_img, '_c0-510-300-810'))
        transmog.cropname = "cropped"
        _, proc_name = os.path.split(transmog.get_processed_filename())

        self.assertEqual(proc_name, self.cropname_img)
    def test_crop_bbox(self):
        expected_square = (300, 300)
        transmog = Transmogrify(utils.generate_url(self.square_img, '_c100-100-400-400'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)

        transmog = Transmogrify(utils.generate_url(self.vert_img, '_c0-100-300-400'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)

        transmog = Transmogrify(utils.generate_url(self.horiz_img, '_c0-410-300-710'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)

        # 810 is larger than the image, PIL adds black to the extra space.
        # who knows if this is desirable but at least it doesn't raise
        # an exception.
        transmog = Transmogrify(utils.generate_url(self.horiz_img, '_c0-510-300-810'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)
 def test_crop(self):
     expected_square = (300, 300)
     transmog = Transmogrify(utils.generate_url(self.square_img, '_c300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
     transmog = Transmogrify(utils.generate_url(self.vert_img, '_c300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
     transmog = Transmogrify(utils.generate_url(self.horiz_img, '_c300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
 def test_resize(self):
     expected_square = (300, 300)
     expected_vert = (168, 300)
     expected_horiz = (300, 208)
     # expected_animated = (300, 214)
     transmog = Transmogrify(utils.generate_url(self.square_img, '_r300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
     transmog = Transmogrify(utils.generate_url(self.vert_img, '_r300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_vert, img.size)
     transmog = Transmogrify(utils.generate_url(self.horiz_img, '_r300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_horiz, img.size)
     transmog = Transmogrify(utils.generate_url(self.horiz_img, '_r300x300'), "")
 def test_thumbnail(self):
     expected_square = (300, 300)
     expected_vert = (168, 300)
     expected_horiz = (300, 208)
     # expected_animated = (300, 214)
     transmog = Transmogrify(
         utils.generate_url(self.square_img, '_r300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
     transmog = Transmogrify(utils.generate_url(self.vert_img, '_r300x300'),
                             "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_vert, img.size)
     transmog = Transmogrify(
         utils.generate_url(self.horiz_img, '_r300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_horiz, img.size)
Beispiel #10
0
    def test_border(self):
        transmog = Transmogrify(utils.generate_url(self.square_img, '_b3-f00'))
        transmog.save()
        transmog = Transmogrify(utils.generate_url(self.vert_img, '_b3-f00'))
        transmog.save()
        transmog = Transmogrify(utils.generate_url(self.horiz_img, '_b3-f00'))
        transmog.save()

        security_hash = utils.generate_url(self.horiz_img,
                                           '_b3-f00').split('?')[1]
        self.assertEqual(security_hash, transmog.get_security_hash())
Beispiel #11
0
 def test_letterbox(self):
     transmog = Transmogrify(
         utils.generate_url(self.square_img, '_l300x300-888'))
     transmog.save()
     transmog = Transmogrify(
         utils.generate_url(self.vert_img, '_l300x300-888'))
     transmog.save()
     transmog = Transmogrify(
         utils.generate_url(self.horiz_img, '_l300x300-888'))
     transmog.save()
Beispiel #12
0
    def test_crop_bbox(self):
        expected_square = (300, 300)
        transmog = Transmogrify(
            utils.generate_url(self.square_img, '_c100-100-400-400'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)

        transmog = Transmogrify(
            utils.generate_url(self.vert_img, '_c0-100-300-400'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)

        transmog = Transmogrify(
            utils.generate_url(self.horiz_img, '_c0-410-300-710'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)

        # 810 is larger than the image, PIL adds black to the extra space.
        # who knows if this is desirable but at least it doesn't raise
        # an exception.
        transmog = Transmogrify(
            utils.generate_url(self.horiz_img, '_c0-510-300-810'), "")
        transmog.save()
        img = Image.open(transmog.get_processed_filename())
        self.assertEqual(expected_square, img.size)
Beispiel #13
0
 def test_crop(self):
     expected_square = (300, 300)
     transmog = Transmogrify(
         utils.generate_url(self.square_img, '_c300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
     transmog = Transmogrify(utils.generate_url(self.vert_img, '_c300x300'),
                             "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)
     transmog = Transmogrify(
         utils.generate_url(self.horiz_img, '_c300x300'), "")
     transmog.save()
     img = Image.open(transmog.get_processed_filename())
     self.assertEqual(expected_square, img.size)