Example #1
0
    def test_invalid_file(self):
        invalid_file = "Tests/images/flower.jpg"

        self.assertRaises(SyntaxError,
                          lambda: TiffImagePlugin.TiffImageFile(invalid_file))

        TiffImagePlugin.PREFIXES.append(b"\xff\xd8\xff\xe0")
        self.assertRaises(SyntaxError,
                          lambda: TiffImagePlugin.TiffImageFile(invalid_file))
        TiffImagePlugin.PREFIXES.pop()
Example #2
0
    def test_invalid_file(self):
        invalid_file = "Tests/images/flower.jpg"

        with pytest.raises(SyntaxError):
            TiffImagePlugin.TiffImageFile(invalid_file)

        TiffImagePlugin.PREFIXES.append(b"\xff\xd8\xff\xe0")
        with pytest.raises(SyntaxError):
            TiffImagePlugin.TiffImageFile(invalid_file)
        TiffImagePlugin.PREFIXES.pop()
Example #3
0
def retraw(img):
    # Load the image into the metadata
    # grab the iptc data

    # some stuff doesn't have metadata for whatever reason ()
    try:
        im = TiffImagePlugin.TiffImageFile(img)
        # set up our regex
        iptc = im.tag.tagdata[TiffImagePlugin.PHOTOSHOP_CHUNK]
        regex = re.findall(r"\/ser=1", iptc)
        # if regex is true it will return back a value so check that and then
        # return
        if regex:
            print(img, strip_control_characters(iptc))
            # extract the data from the tag and return it and the i mage path
            # in a tuple
    except Exception as e:
        print(e)
        # just fugettahboutit
        return
Example #4
0
    def test_invalid_file(self):
        invalid_file = "Tests/images/flower.jpg"

        self.assertRaises(SyntaxError,
                          lambda: TiffImagePlugin.TiffImageFile(invalid_file))