Iโm not sure that you can achieve this, since the amount of information that a QR code can store is quite limited.
First of all, you probably want to save your image as raw bytes, as other formats (numeric and alphanumeric) are designed to store text / numbers and provide less space for image storage. Suppose you select the largest possible QR code (version 40) with the lowest level of error correction, which can contain up to 2953 bytes of binary information (see here) .
The first option, as you think, will save the image as a bitmap. This format does not allow any compression at all and requires (in the case of an RGB image without an alpha channel) 3 bytes per pixel. If we take into account the size of the file header (from 14 to 54 bytes) and ignore the filling (each line of image data must be supplemented by a length multiple of 4), which allows us to store approximately 2900/3 = 966 pixels. If we look at a square image, this is a 31x31 bitmap, which is small even for a thumbnail image (for example, my avatar at the end of this post is 32x32 pixels).
The second option, you use JPEG to encode the image. The advantage of this format is the use of a compression algorithm that can reduce file size. This time there is no exact formula to get an image size of 2.9 kB, but I tried to use several square images and reduced them until they fit in that size, preserving a good (93) quality factor: this gives an average value about 60x60 pixels. (In such small images, it is usually not possible to see an incredible compression ratio between jpeg and bmp, since the file header in the jpeg file is much larger than in the bmp file: about 500 bytes). This is better than a bitmap, but it remains quite small.
Finally, even if you manage to encode your image in this QR code, you will run into another problem: the QR code, this large one, is very, very difficult to scan. In essence, this QR code will have a size of 177x177 modules (the โmoduleโ is a small white or black square). Assuming that you scan it using a smartphone that provides the so-called "HD" frames (1280x720 pixels), each module will have a maximum frame size of about 4 pixels. If you take into account camera noise, overlap and blur due to the fact that the user is never inactive during scanning, the quality of the input frames will make it very difficult for any QR code decoding algorithm to successfully receive a QR code Code (do not forget to set the level of bug fixes is low at the beginning of this!).
Although this is not good news, I hope this helps you!
mbrenon
source share