Created
January 31, 2017 14:44
-
-
Save RaminNietzsche/3e94f1c5a891a042c5dbc5d0dc5733e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from PIL import Image | |
| im = Image.open("/home/ramin/Pictures/mine/s1_3.jpg") | |
| n_im = Image.new("RGB", im.size) | |
| msg = ''' | |
| PYOTR PETROVITCH STRIZHIN, the nephew of Madame Ivanov, the colonel's widow -- the man whose new goloshes were stolen last year, -- came home from a christening party at two o'clock in the morning. To avoid waking the household he took off his things in the lobby, made his way on tiptoe to his room, holding his breath, and began getting ready for bed without lighting a candle. | |
| Strizhin leads a sober and regular life. He has a sanctimonious expression of face, he reads nothing but religious and edifying books, but at the christening party, in his delight that Lyubov Spiridonovna had passed through her confinement successfully, he had permitted himself to drink four glasses of vodka and a glass of wine, the taste of which suggested something midway between vinegar and castor oil. Spirituous liquors are like sea-water and glory: the more you imbibe of them the greater your thirst. And now as he undressed, Strizhin was aware of an overwhelming craving for drink. | |
| "I believe Dashenka has some vodka in the cupboard in the right-hand corner," he thought. "If I drink one wine-glassful, she won't notice it." | |
| ''' | |
| count = 0 | |
| for w in range(im.width): | |
| for h in range(im.height): | |
| r, g, b = im.getpixel((w, h)) | |
| if w * h % 57 == 0: | |
| if count < len(msg): | |
| n_im.putpixel((w, h),(r, g, ord(msg[count]))) | |
| count += 1 | |
| else: | |
| n_im.putpixel((w, h),(r, g, b)) | |
| n_im.save("/home/ramin/Pictures/mine/s1_n.png", "PNG") | |
| n_im.close() | |
| text = "" | |
| s_im = Image.open("/home/ramin/Pictures/mine/s1_n.png") | |
| for w in range(s_im.width): | |
| for h in range(s_im.height): | |
| r, g, b = s_im.getpixel((w, h)) | |
| if w * h % 57 == 0: | |
| if b == 0: | |
| print(text) | |
| exit(0) | |
| text += chr(b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment