Example #1
0
def unbake(imageFile):
    """
    Return the openbadges content contained in a baked image.
    """
    image_type = check_image_type(imageFile)
    imageFile.seek(0)
    if image_type == 'PNG':
        return png_bakery.unbake(imageFile)
    elif image_type == 'SVG':
        raise NotImplementedError("SVG UNBAKING COMING SOON.")
Example #2
0
def unbake(imageFile):
    """
    Return the openbadges content contained in a baked image.
    """
    image_type = check_image_type(imageFile)
    imageFile.seek(0)
    if image_type == 'PNG':
        return png_bakery.unbake(imageFile)
    elif image_type == 'SVG':
        raise NotImplementedError("SVG UNBAKING COMING SOON.")
Example #3
0
    def test_bake_png(self):
        with open(os.path.join(os.path.dirname(__file__),
                               'testfiles', 'public_domain_heart.png'
                               )) as image:

            return_file = png_bakery.bake(image, json.dumps(test_assertion))
            return_file.open('r')
            self.assertEqual(utils.check_image_type(return_file), 'PNG')
            return_file.close()
            return_file.open('r')
            self.assertEqual(png_bakery.unbake(return_file), json.dumps(test_assertion))
Example #4
0
 def test_unbake_png(self):
     with open(os.path.join(os.path.dirname(__file__),
                            'testfiles', 'baked_heart.png'
                            )) as image:
         assertion = png_bakery.unbake(image)
         self.assertEqual(json.loads(assertion), test_assertion)