Javascript无损图像压缩 [英] Javascript lossless image compression
问题描述
我正在寻找一种方法来将bmp图像编码为tiff或其他一些标准的,压缩但无损的浏览器格式(javascript)。我想如果最坏的情况发生,我可以自己编写一个库(从canvas元素中获取数据),但我希望:或者有更好的方法,或者其他人已经写过类似的东西(我找不到一个图书馆)。
I am looking for a way to encoding a bmp image as a tiff or some other standard, compressed but lossless format in a browser (javascript). I guess if worst comes to worst I can write a library myself (getting the data from a canvas element) but I was hoping either: there's a better way to do it or someone else has already written something similar (I can't find a library).
我有用户想要上传〜4mb(8位单色)bmp文件,我可以用LZW无损压缩到~700kb tiff文件(甚至更好~300kb无损JPEG-2000)。我想在上传文件之前这样做以节省转移费用/时间。
I have users wanting to upload ~ 4mb (8-bit monochrome) bmp files, which I can losslessly compress to ~700kb tiff files with LZW (or even better ~300kb lossless JPEG-2000). I'd like to do this before the files are uploaded to save transfer costs/time.
在你问之前,我不是在讨论无损编码而不是只使用高比特率JPEG。这些是用于分析的天文照片,因此它们无法处理所引入的任何压缩工件。
Before you ask, I'm not being anal about the lossless encoding instead of just using high bitrate JPEG. These are astronomy photos that are used for analysis so they can't handle any compression artifacts being introduced.
谢谢,
Jonny
Thanks, Jonny
推荐答案
使用PNG。它是无损的并且使用zlib压缩。甚至有像 pngcrush 这样的程序可以优化图像的大小(唯一的问题是它需要一段时间对于这个)。
Use PNG. It's lossless and uses zlib compression. There are even programs like pngcrush that will optimize the image for size (only problem is it takes a while for this).
你是否有任何理由在这个过程中使用JavaScript?从长远来看,如果你在Java applet中做到这一点(使用与 java.awt.Image
class),或将其上传到执行该操作的服务器图像处理并返回压缩图像?
Is there any reason you're using JavaScript of all things for this process? Wouldn't it be easier in the long run if you did it in a Java applet (using a library that interfaces with the java.awt.Image
class), or uploaded it to a server that did the image processing and returned the compressed image?
编辑:请不要使用Java小程序;该技术不再受到良好支持。
Please don't use a Java applet; the technology isn't well-supported anymore.
这篇关于Javascript无损图像压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!