Advertisement
AshTurner67

NOCAP

Oct 18th, 2024 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. # Read the .nocap file
  4. with open('file.nocap', 'r') as file:
  5.     data = file.read()
  6.  
  7. # Replace characters with binary values
  8. binary_data = data.replace('?', '0').replace('!', '1')
  9.  
  10. # Define the dimensions (width can be adjusted)
  11. width = 100  # Example width
  12. height = len(binary_data) // width  # Calculate height based on the width
  13.  
  14. # Create a new image
  15. image = Image.new('1', (width, height))  # '1' for 1-bit pixels (black and white)
  16.  
  17. # Populate the image with pixel data
  18. pixels = [int(bit) for bit in binary_data]  # Convert to a list of integers
  19. image.putdata(pixels)
  20.  
  21. # Save or show the image
  22. image.save('output_image.png')
  23. image.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement