Skip to content
Go back

Instagram Cloud Storage — Binary Image Encoder

Overview

This project explores an unconventional approach to cloud storage: encoding text data as black-and-white pixel images and uploading them to image-hosting platforms. Each pixel in the output image represents a single bit — white (255) for 1, black (0) for 0 — making any text file visually reconstructable from a saved image.

View on GitHub


How It Works

The pipeline has two core stages:

1. Text → Binary String

Every character in the input file is converted to its 8-bit ASCII binary representation using Python’s format(ord(char), '08b'). The resulting string is a flat sequence of 0s and 1s.

2. Binary String → Image

The binary string is reshaped into a 2D array of a user-defined width. Each 0 or 1 maps to a black or white pixel respectively. The image is written as a 3-channel (RGB) array using NumPy and saved via OpenCV.


Code Breakdown

ComponentDescription
text_to_binary(text)Converts a string to a flat binary representation
binary_to_image(binary_string, width)Reshapes binary data into an OpenCV-compatible image array
image_widthControls the pixel width of the output (and therefore image height)
cv2.imwrite()Saves the final image as a .png file

Dependencies

Install with:

pip install opencv-python numpy

Usage

  1. Place your text content in input.txt
  2. Set your preferred image_width (e.g. 20 pixels wide)
  3. Run the script:
python encoder.py

The encoded image is saved as savedfile.png and displayed in a preview window.


Example

A plain text file containing Hello (5 characters × 8 bits = 40 bits) with image_width = 20 produces a 2 × 20 pixel image — each row representing 20 bits of the message.


Notes & Limitations


Potential Extensions


Share this post on:

Previous Post
Hello World