Example #1
0
 def test_pil(self):
     src = "test/person.jpg"
     i = Image.from_file(src)
     sz1 = i.size()
     i2 = Image.from_pil(i.to_pil())
     sz2 = i2.size()
     self.assertEquals(sz1, sz2)
Example #2
0
 def test_pil(self):
     src = 'test/person.jpg'
     i = Image.from_file(src)
     sz1 = i.size()
     i2 = Image.from_pil(i.to_pil())
     sz2 = i2.size()
     self.assertEquals(sz1, sz2)
Example #3
0
    def test_basic_text(self):
        try:
            i = Image(Url('http://www.cs.unc.edu/~karl/Images/nav.jpg'))
            self.assertEqual(i.size(), (893, 446))

            images = set(Page(Url('http://www.cs.unc.edu/~karl')).images())
            self.assertEqual(len(images), 1)
            self.assertTrue(i in images)
        except:
            pass
Example #4
0
    def test_basic_text(self):
        try:
            i = Image(Url("http://www.cs.unc.edu/~karl/Images/nav.jpg"))
            self.assertEqual(i.size(), (893, 446))

            images = set(Page(Url("http://www.cs.unc.edu/~karl")).images())
            self.assertEqual(len(images), 1)
            self.assertTrue(i in images)
        except:
            pass
Example #5
0
 def test_estimate_compression(self):
     with config.fake_proxy():
         i = Image("http://radioprimetime.org/specials/focusspecials/images/dog2.jpg")
         self.assertAlmostEquals(i.estimate_compression(), 0.528500932546)
         i = Image("http://www.costumedogs.com/wp-content/uploads/2007/07/tux.jpg")
         self.assertAlmostEquals(i.estimate_compression(), 0.989372469636)
         i = Image("http://www.freefoto.com/images/01/07/01_07_1---Pair-of-Dogs_web.jpg?&k=Pair+of+Dogs")
         self.assertAlmostEquals(i.estimate_compression(), 0.268289197942)
Example #6
0
 def test_estimate_compression(self):
     with config.fake_proxy():
         i = Image(
             'http://radioprimetime.org/specials/focusspecials/images/dog2.jpg'
         )
         self.assertAlmostEquals(i.estimate_compression(), 0.528500932546)
         i = Image(
             'http://www.costumedogs.com/wp-content/uploads/2007/07/tux.jpg'
         )
         self.assertAlmostEquals(i.estimate_compression(), 0.989372469636)
         i = Image(
             'http://www.freefoto.com/images/01/07/01_07_1---Pair-of-Dogs_web.jpg?&k=Pair+of+Dogs'
         )
         self.assertAlmostEquals(i.estimate_compression(), 0.268289197942)
Example #7
0
 def xxx_test_extract_text(self):
     # XXX
     i = Image(config.fake_server('images/test_ocr.jpg'))
     self.assertEquals(i.text().rstrip(), 'Hello World!')
Example #8
0
 def test_entropy(self):
     with config.fake_proxy():
         i = Image('http://www.cs.unc.edu/~karl/me.jpg')
         self.assertAlmostEquals(i.entropy(), 8.67911685935)
         i = Image(config.fake_server('images/test_ocr.jpg'))
         self.assertAlmostEquals(i.entropy(), 5.2323108617)
Example #9
0
 def test_url(self):
     with config.fake_proxy():
         i = Image('http://www.cs.unc.edu/~karl/me.jpg')
         self.assertEquals(i.url(),
                           Url('http://www.cs.unc.edu/~karl/me.jpg'))
Example #10
0
 def test_from_file(self):
     with config.fake_proxy():
         i1 = Image.from_file('test/person.jpg')
         i2 = Image('http://www.cs.unc.edu/~karl/me.jpg')
         self.assertEquals(i1.area(), i2.area())
Example #11
0
 def test_entropy(self):
     i = Image(config.fake_server('images/test_ocr.jpg'))
     self.assertAlmostEquals(i.entropy(), 5.2323108617)
Example #12
0
 def xxx_test_extract_text(self):
     # XXX
     i = Image(config.fake_server("images/test_ocr.jpg"))
     self.assertEquals(i.text().rstrip(), "Hello World!")
Example #13
0
 def test_entropy(self):
     with config.fake_proxy():
         i = Image("http://www.cs.unc.edu/~karl/me.jpg")
         self.assertAlmostEquals(i.entropy(), 8.67911685935)
         i = Image(config.fake_server("images/test_ocr.jpg"))
         self.assertAlmostEquals(i.entropy(), 5.2323108617)
Example #14
0
 def test_url(self):
     with config.fake_proxy():
         i = Image("http://www.cs.unc.edu/~karl/me.jpg")
         self.assertEquals(i.url(), Url("http://www.cs.unc.edu/~karl/me.jpg"))
Example #15
0
 def test_from_file(self):
     with config.fake_proxy():
         i1 = Image.from_file("test/person.jpg")
         i2 = Image("http://www.cs.unc.edu/~karl/me.jpg")
         self.assertEquals(i1.area(), i2.area())
Example #16
0
 def test_entropy(self):
     i = Image(config.fake_server("images/test_ocr.jpg"))
     self.assertAlmostEquals(i.entropy(), 5.2323108617)