Encryption works in a stream of bytes. That is, it takes an array of bytes and outputs another array of bytes. Images are also an array of bytes. We assign the "r" component of the upper left pixel for the first byte, the "g" component to the second byte, the "b" component to the third byte. The “r” component of the pixel next to it is the fourth byte, etc.
So, to "encrypt" an image, you simply take a byte array of pixels in the first image, encrypt it (encryption usually does not change the number of bytes - in addition to filling) and uses these encrypted bytes as pixel data for the second image.
, . (, JPEG ..). , , "" .