Not sure what speed you expect but it could be as simple as this with Pillow:
from PIL import Image
import numpy as np
Image.MAX_IMAGE_PIXELS = 933120000
# Load image as PIL Image and make into Numpy array
im = Image.open('eta.jpg')
na = np.array(im)
# Mask LSBs and ensure small storage allocation of np.uint8
LSBs = (na & 1).astype(np.uint8)
LSBs.tofile('filename.bin')
Note that you could compress the data before writing. Here's the code for gzip but you can change the word gzip to lzma or bz2 to try other methods:
# Generate some random data
LSBs = np.random.randint(2, size=(20_000, 14_000, 3), dtype=np.uint8).tobytes()
import gzip
compressed = gzip.compress(LSBs)
from pathlib import Path
Path('compressed.bin').write_bytes(compressed)
If you want to save the LSBs as a PNG, start with my original code and add this to the end:
# Mask LSBs and ensure small storage allocation of np.uint8
LSBs = (na & 1).astype(np.uint8)
# Make LSBs into PIL Image and save
pi = Image.fromarray(LSBs)
pi.save('LSBs.png')
You can also try replacing the final line with:
pi.save('LSBs.png', optimize=True)
Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." Also question language tagged should contain question related to those languages. Removedlibvipsis likely to be fast and efficient for this.