Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
PicEncode
-
I saw BioLib I decided to do a project based of there code to store data in the whole RGB value of a pixel. I also made it so that it can make a block image in stead of a 1 - pixel strip. I have plans to make a system to allow for scanning of it from a picture of the code. But that will take some time as I look in to how to do error correction. (Which might be make it use 4 pixels per pixel to get rid of error)
The my basic code before I start working on the scan ability features is:
# coding: utf-8 from PIL import Image import sys def encode(filename,plain_text,X=16): # returns true or false depending on if it successfully saves the photo. g = 0 b = X while not len(plain_text)/3 == len(plain_text)/3.0: plain_text = plain_text +'a' g = g+1 r = 0 x = 1 y = 0 if b > (len(plain_text)/3): b = (len(plain_text)/3) + 1 test = [plain_text[i:i+3] for i in range(0, len(plain_text), 3)] for t in test: if x == b: x = 0 y = y + 1 x = 1 + x r = (b - (len(test)%b))//256 x = 1 z = y +1 y = 0 bioMessage = Image.new("RGB",(b,z),(255,255,255)) bioMessageLoaded = bioMessage.load() for t in test: if x == b: x = 0 y = y + 1 asciiEdition1 = int(ord(t[0])) asciiEdition2 = int(ord(t[1])) asciiEdition3 = int(ord(t[2])) #print asciiEdition1,asciiEdition2,asciiEdition3 bioMessageLoaded[x,y] = (asciiEdition1,asciiEdition2,asciiEdition3) x = 1 + x b = (b - (len(test)%b))%256 bioMessage.putpixel((0,0),(r,g,b)) bioMessage.save(filename) def decode(filename): print "Decoding" image = Image.open(filename) r,g,b = image.getpixel((0,0)) r = r*256 + b pixels = {} t =0 for y in xrange(image.size[1]): for x in xrange(image.size[0]): pixels[t] = image.getpixel((x,y)) t=t+1 char_set = [] for x in pixels.keys(): if x > 0: t = pixels[x] char_set.append(t[0]) char_set.append(t[1]) char_set.append(t[2]) test = char_set if not r == 0: real_data = char_set[:(-r*3)+3] else: real_data =char_set data = '' for x in real_data: data = data + chr(x) if not g ==0: data =data[:-g] return data
Data about the image is stored in the first pixel of all the pixels in the top left corner. This includes the amount of extra white pixels at the bottom and also the amount of 'filler' to add to make the data divisible by 3. The extra data is stored as the int of division and the remainder to allow for huge images.
If your reading in binary data make sure to write it out after you decode it as binary. I was hunting for a bug because I forgot that.
-
I did some math and with a "Standard" Printer you can fit at least a 6 mb file. But the question is can you read it back it? That I need to work on. The only problem I see is that the camera or scanner will not have enough pixels and mix the pixels together.
I will also attach the picture generated by converting the actual Picture code.
Here is the PicEncode as an encoded image. PicEncode
-
We should start a group, and collaborate on this. I think it'd be interesting.
I have a really good idea that will make data corruption from compression software, or something of that matter innate. Because currently, if you were to send an image across Gmail, or a platform of that nature, it'd compress the file's RGB color values, and make the image virtually unreadable. I have a good plan to fix this, and make this software a robust, reliable program.
Again, we need to collaborate on this.
-
Yeah. I could make us a github repo that you have push access to. Also my plan for color correction it that like we codes use things around the edges. I will be using colors around the edge to find the changes to the rgb values from there base.
-
It is not clear to me if you are just trying to use an image as a data container, trying to create a kind of barcode, or are trying to add hidden data into and image. In any case many of the issues your are thinking about are covered in the area of imaging technology called Stegonography. This is the embedding of data into an image and its retrieval from the image after it has gone through various transformations including lossy compression. Let's just say - it is heavily researched and many companies have lived and died implementing various techniques. The most famous one is Digimarc. There are also numerous open source "Stego" projects out there that are worth exploring.
-
If this turns into a collaboration, I definitely think the code should be more readable. I also do like the idea of the 1px dimensions.
It would be nice to see both form implemented. Interesting topic.
-
I have not been able to work on this the whole week because of theater.
-
@wradcliffe I understand this. I have heard of Steganography before, and I know what it is. I just haven't been able to do something of this magnitude before considering I just barely learned about how to manipulate image files.
-
-
Interesting. Well right now I am completely rewriting this because I accidentally deleted Pythonista on my iPad...
-
https://github.com/fgrimme/Matroschka Another pure Python implementation. From Berlin.
-
Sorry for the crazy bump.
But I am not doing steganography. As I am not hiding data inside of a image. It's more of I am storing the data as pixels instead of as normal binary.