I'm creating barcodes on the fly, and embedding them in web pages. What format should I use? I'm wavering between JPG and PNG, and I don't really understand the advantages of both. Size matters in this, as does readability (better a clear barcode than a blurry one). Is there another format that would be better yet?
我正在创建条形码,并将它们嵌入到网页中。我应该使用什么格式?我在JPG和PNG之间摇摆不定,我真的不明白两者的优点。尺寸在这方面很重要,可读性也是如此(更清晰的条形码比模糊条形码更好)。还有其他格式会更好吗?
6 个解决方案
#1
PNG, or even GIF. Jpeg is right out, because it's designed for the smooth gradients of photographs, not the sharp edges of bar codes. Draw a simple Bar code by hand in MS Paint, save it, and then reload it, you'll see all kinds of compression artifacts.
PNG,甚至是GIF。 Jpeg是正确的,因为它专为照片的平滑渐变而设计,而不是条形码的锐利边缘。在MS Paint中手工绘制一个简单的条形码,保存它,然后重新加载它,你会看到各种压缩工件。
#2
Definitely PNG. It's much better at storing vector graphics, such as bar codes (as opposed to photos).
绝对是PNG。它在存储矢量图形方面要好得多,例如条形码(与照片相对)。
Wikipedia has a nice comparison of JPG vs. PNG.
*对JPG与PNG进行了很好的比较。
#3
PNG should be better than JPG (JPG is lossy). GIF might be even better since the image is going to be monochrome (but check it in your case).
PNG应该优于JPG(JPG是有损的)。 GIF可能会更好,因为图像将是单色的(但在你的情况下检查它)。
#4
PNG is the better option between PNG and JPG. The main issue here is of compression - there are two forms of compression techniques in images, lossy and lossless. Lossy compression algorithms (such as the one used by JPG files) "lose" information during the compression->decompression cycle. 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 imagery prior to the initial saving.
PNG是PNG和JPG之间更好的选择。这里的主要问题是压缩 - 图像中有两种形式的压缩技术,有损和无损。有损压缩算法(例如JPG文件使用的算法)在压缩 - >解压缩循环期间“丢失”信息。因此,图像中会出现伪影。另一方面,PNG使用无损压缩,因此显示的图像将与初始保存之前的原始未压缩图像完全相同。
In the case of barcodes, the exact pixel-by-pixel placement of black/white is very important (that's the entire point), so using a lossy compression routine like JPG could be very bad. If you're using a 2D barcode, it will be even worse, and your scanner may have a very difficult time reading the barcode accurately. PNG will completely eliminate this problem.
在条形码的情况下,黑/白的精确逐像素放置非常重要(这是整个点),因此使用像JPG这样的有损压缩程序可能非常糟糕。如果您使用的是二维条码,情况会更糟,扫描仪可能很难准确读取条形码。 PNG将完全消除这个问题。
#5
I have used .gif and .png successfully. My answer (and other answers, to be fair) to this question has more detail.
我成功地使用了.gif和.png。我对这个问题的答案(以及其他答案,公平)有更多细节。
#6
PNG all the way. It will not only avoid the compression artifacts you'll get with JPG, but will almost certainly yield better compression as well. JPG is very badly suited to images with sharp edges.
PNG一路走来。它不仅可以避免使用JPG获得的压缩工件,而且几乎肯定会产生更好的压缩效果。 JPG非常适合具有锐边的图像。
#1
PNG, or even GIF. Jpeg is right out, because it's designed for the smooth gradients of photographs, not the sharp edges of bar codes. Draw a simple Bar code by hand in MS Paint, save it, and then reload it, you'll see all kinds of compression artifacts.
PNG,甚至是GIF。 Jpeg是正确的,因为它专为照片的平滑渐变而设计,而不是条形码的锐利边缘。在MS Paint中手工绘制一个简单的条形码,保存它,然后重新加载它,你会看到各种压缩工件。
#2
Definitely PNG. It's much better at storing vector graphics, such as bar codes (as opposed to photos).
绝对是PNG。它在存储矢量图形方面要好得多,例如条形码(与照片相对)。
Wikipedia has a nice comparison of JPG vs. PNG.
*对JPG与PNG进行了很好的比较。
#3
PNG should be better than JPG (JPG is lossy). GIF might be even better since the image is going to be monochrome (but check it in your case).
PNG应该优于JPG(JPG是有损的)。 GIF可能会更好,因为图像将是单色的(但在你的情况下检查它)。
#4
PNG is the better option between PNG and JPG. The main issue here is of compression - there are two forms of compression techniques in images, lossy and lossless. Lossy compression algorithms (such as the one used by JPG files) "lose" information during the compression->decompression cycle. 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 imagery prior to the initial saving.
PNG是PNG和JPG之间更好的选择。这里的主要问题是压缩 - 图像中有两种形式的压缩技术,有损和无损。有损压缩算法(例如JPG文件使用的算法)在压缩 - >解压缩循环期间“丢失”信息。因此,图像中会出现伪影。另一方面,PNG使用无损压缩,因此显示的图像将与初始保存之前的原始未压缩图像完全相同。
In the case of barcodes, the exact pixel-by-pixel placement of black/white is very important (that's the entire point), so using a lossy compression routine like JPG could be very bad. If you're using a 2D barcode, it will be even worse, and your scanner may have a very difficult time reading the barcode accurately. PNG will completely eliminate this problem.
在条形码的情况下,黑/白的精确逐像素放置非常重要(这是整个点),因此使用像JPG这样的有损压缩程序可能非常糟糕。如果您使用的是二维条码,情况会更糟,扫描仪可能很难准确读取条形码。 PNG将完全消除这个问题。
#5
I have used .gif and .png successfully. My answer (and other answers, to be fair) to this question has more detail.
我成功地使用了.gif和.png。我对这个问题的答案(以及其他答案,公平)有更多细节。
#6
PNG all the way. It will not only avoid the compression artifacts you'll get with JPG, but will almost certainly yield better compression as well. JPG is very badly suited to images with sharp edges.
PNG一路走来。它不仅可以避免使用JPG获得的压缩工件,而且几乎肯定会产生更好的压缩效果。 JPG非常适合具有锐边的图像。