Example #1
0
def steg(cover_path, hidden_path):
    '''
    Function to hide data (either an image or text) within another image
    INPUT: string, path to the cover image; string, path to the hidden data
    OUTPUT: a new image with the hidden data encoded in the least significant
    bits
    '''
    if hidden_path[-4:] == '.txt':
        text.encrypt(cover_path, hidden_path)
    else:
        image.merge(cover_path, hidden_path)
Example #2
0
    def testImageMergeLimit(self):
        MAX_IMAGES = 1024

        # this one shouldn't throw. It's a bit slow, disable for faster
        # testing.
        if True:
            images = list(itertools.repeat(
                          self._getImg("img1.png"), MAX_IMAGES))
            merge(images)

        def doTest():
            images = list(itertools.repeat(
                          self._getImg("img1.png"), MAX_IMAGES + 1))
            merge(images)
        self.assertRaises(SystemError, doTest)
Example #3
0
    def merge(self, tiles, params):
        images = []
        for t in tiles:
            (format, data) = self.service.renderTile(t, params.has_key('FORCE'))
            if data is None:
                continue
            images.append(data)

        if not images:
            return (format, None)

        import image_merge
        preserve_colors = self.service.metadata.get(
            "image_merge_preserve_colors") in ("true", "on", "yes", "1")
        return (format, image_merge.merge(images, preserve_colors))
Example #4
0
        def merge_pixels(input_pixels, preserve_colors, expected_output_pixel):
            images = []
            for p in input_pixels:
                pil_img = Image.new("RGBA", (1, 1))
                pil_img.putdata([p])

                buffer = StringIO.StringIO()
                pil_img.save(buffer, "PNG")
                buffer.seek(0)
                images.append(buffer.read())

            result = merge(images, preserve_colors=preserve_colors)
            self.assertPNGImage(result)
            pil_result = Image.open(StringIO.StringIO(result))

            self.assertEquals(pil_result.getdata()[0], expected_output_pixel)
Example #5
0
    def testMergeImage(self):
        img = merge([self._getImg("img1.png")])
        self.assertPNGImage(img)

        img = merge([self._getImg("img1.png"), self._getImg("img2.png")])
        self.assertPNGImage(img)
Example #6
0
 def testInvalidParams(self):
     self.assertRaises(TypeError, lambda: merge(1))
     self.assertRaises(TypeError, lambda: merge("foo", "bar", []))
     self.assertRaises(SystemError, lambda: merge([]))
     self.assertRaises(TypeError, lambda: merge([1]))
     self.assertRaises(TypeError, lambda: merge(["foo", "bar", []]))
Example #7
0
 def doTest():
     merge([self._getImg("img1.png"), self._getImg("img1-10x10.png")])
Example #8
0
 def doTest():
     merge([self._getImg("img1.png"), "foo"])
Example #9
0
 def testUnsupportedFormat(self):
     self.assertRaises(SystemError, lambda: merge(["foo"]))
     def doTest():
         merge([self._getImg("img1.png"), "foo"])
     self.assertRaises(SystemError, doTest)
Example #10
0
 def doTest():
     images = list(itertools.repeat(
                   self._getImg("img1.png"), MAX_IMAGES + 1))
     merge(images)