示例#1
0
def test_missing_config(tclip_sample):
    src_path, dst_path = tclip_sample
    clip = TClip(200, 200)
    clip.config_path = None

    with raises(RuntimeError):
        clip.process_file(str(src_path), str(dst_path))
示例#2
0
def test_can_work(tclip_sample):
    src_path, dst_path = tclip_sample
    clip = TClip(200, 200)

    with Image(filename=str(src_path)) as image:
        assert abs(image.width - 200) > 5
        assert abs(image.height - 200) > 5

    assert clip.process_file(str(src_path), str(dst_path)) == 0

    with Image(filename=str(dst_path)) as image:
        assert abs(image.width - 200) < 5
        assert abs(image.height - 200) < 5
 def test_something(self):
     fp = open('/home/zhenghuabin/images/37d12f2eb9389b5054c9b3608635e5dde7116ec9.jpg', 'r')
     im = Image.open(fp)
     print im.format
     outf = StringIO()
     im.save(outf, "JPEG")
     data = outf.getvalue()
     print(len(data))
     clip = TClip(width = 50, height = 50)
     (ret, rc) = clip.process_buffer(data)
     if ret is None:
         print rc 
     else:
         print("type: %d" % rc)
         out2 = open('/home/zhenghuabin/tt.jpeg', 'w')
         out2.write(ret)
     self.assertEqual(True, True)