我应该使用什么图像格式来动态创建条形码
我正在即时创建条形码,并将它们嵌入网页中。 我应该使用什么格式? 我在JPG和PNG之间犹豫不决,不太了解两者的优点。 尺寸很重要,可读性也很重要(清晰的条形码比模糊的条形码更好)。 还有其他格式会更好吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
PNG,甚至 GIF。 Jpeg 是正确的,因为它是为照片的平滑渐变而不是条形码的锐利边缘而设计的。 在 MS Paint 中手工绘制一个简单的条形码,保存它,然后重新加载它,您将看到各种压缩伪影。
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。 它更擅长存储矢量图形,例如条形码(而不是照片)。
维基百科有一个很好的JPG 与 PNG 的比较。
Definitely PNG. It's much better at storing vector graphics, such as bar codes (as opposed to photos).
Wikipedia has a nice comparison of JPG vs. PNG.
PNG应该比 JPG 更好(JPG 是有损的)。 GIF 可能会更好,因为图像将是单色的(但请根据您的情况进行检查)。
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 是 PNG 和 JPG 之间更好的选择。 这里的主要问题是压缩 - 图像中有两种形式的压缩技术:有损和无损。 有损压缩算法(例如 JPG 文件使用的算法)在压缩→解压缩循环期间“丢失”信息。 因此,您的图像中将会出现伪影。 另一方面,PNG 使用无损压缩,因此显示的图像将与初始保存之前的原始未压缩图像完全相同。
对于条形码,黑/白的精确逐像素放置非常重要(这就是重点),因此使用像 JPG 这样的有损压缩例程可能会非常糟糕。 如果您使用二维条形码,情况会更糟,您的扫描仪可能很难准确读取条形码。 PNG将彻底消除这个问题。
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.
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.
我已成功使用 .gif 和 .png 。 我的答案(公平地说,还有其他答案)这个问题有更多细节。
I have used .gif and .png successfully. My answer (and other answers, to be fair) to this question has more detail.
PNG 一路走来。 它不仅可以避免使用 JPG 时出现的压缩伪影,而且几乎肯定会产生更好的压缩效果。 JPG 非常不适合具有锐利边缘的图像。
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.