Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- # Read the .nocap file
- with open('file.nocap', 'r') as file:
- data = file.read()
- # Replace characters with binary values
- binary_data = data.replace('?', '0').replace('!', '1')
- # Define the dimensions (width can be adjusted)
- width = 100 # Example width
- height = len(binary_data) // width # Calculate height based on the width
- # Create a new image
- image = Image.new('1', (width, height)) # '1' for 1-bit pixels (black and white)
- # Populate the image with pixel data
- pixels = [int(bit) for bit in binary_data] # Convert to a list of integers
- image.putdata(pixels)
- # Save or show the image
- image.save('output_image.png')
- image.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement