What image format should be used for on-the-fly barcodes

I create bar codes on the fly and embed them in web pages. Which format should I use? I hesitate between JPG and PNG, and I do not understand the benefits of both. Size matters, as does readability (a crisp barcode is better than a blurry one). Is there another format that would be even better?

+4
source share
6 answers

PNG or even GIF. Jpeg right away, because it is designed for smooth gradients of photos, not for the sharp edges of barcodes. Draw a simple barcode manually in MS Paint, save it, and then reload it, you will see all kinds of compression artifacts.

+13
source

Definitely PNG. This is much better when storing vector graphics such as barcodes (as opposed to photographs).

Wikipedia has a comparison of JPG and PNG .

+5
source

PNG should be better than JPG (JPG is unprofitable). GIFs might be even better as the image will be monochrome (but check it in your case).

+4
source

PNG is the best option between PNG and JPG. The main problem here is compression - in images there are two forms of compression methods, loss and loss. Lossy compression algorithms (such as those used by JPG files) β€œlose” information during the compression cycle β†’ decompression. Because of this, there will be artifacts in your image. PNG, on the other hand, uses lossless compression, so the displayed image will be exactly the same as the original uncompressed images until the initial saving.

In the case of barcodes, the exact pixel placement of black / white is very important (this is a whole point), so using a lossy compression program like JPG can be very bad. If you use a 2D barcode, it will be even worse and your scanner can read the barcode very quickly. PNG will completely fix this problem.

+2
source

I have successfully used .gif and .png. My answer (and other answers, to be honest) to this question contains more detailed information.

+1
source

PNG completely. This will not only avoid the compression artifacts that you get with JPG, but will almost certainly give you better compression. JPG is very poorly suited for sharp-edged images.

+1
source

Source: https://habr.com/ru/post/1286428/


All Articles