裁剪大 jpeg
有一个任务是编写一个程序来裁剪 JPEG 文件。但问题是某些 jpeg 文件的大小很大 - 数百兆字节。所以问题是:是否可以裁剪 jpeg 文件,但无需将所有文件加载到 RAM,使用 fseek() 之类的东西,并仅解码需要的部分。
这可能吗?如果是的话,也许有一些图书馆也在做同样的事情。
更新。这一切都将用于深度变焦技术。因此,当深度缩放请求文件时,该程序会提供文件,但这应该是实时的
There is a task, to write a programm that will be crope a JPEG files. But the problem is that some jpeg files has large sizes - hundreds of MegaBytes. So the question: Is it possible to crop a jpeg file, but without loading all file to the RAM, using something like fseek(), and decoding only the parts that needed.
Is that possible? If yes, maybe there is some libraries do the same.
Upd. All this will be used for the deep zoom technology. So when deep zoom will asking for a file, this program will give it, but this should be in real time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种方法可以实现此目的。
第一个是无损裁剪,您不需要一直解码文件,而是使用 8x8 DCT 块。您需要使用具有此功能的库,并且它对裁剪能力设置了一些限制。您无法裁剪到不在 DCT 方块上的边界,这会将您限制为 8 或 16 的倍数,具体取决于文件中的子采样。
第二种方法是使用允许您一次读写一行的库。我知道 IJG 库 可以做到这一点,也许其他库也可以做到这一点。这是一种简单的方法,但缺点是图像会经过解压/再压缩过程,并且会降低质量和/或变大。
There are two ways to accomplish this.
The first is lossless cropping, where you don't decode the file all the way but work with the 8x8 DCT blocks. You'll need to use a library that has this capability, and it places some restrictions on the cropping ability. You can't crop to a boundary that isn't on the DCT square, which limits you to multiples of 8 or 16 depending on the subsampling in the file.
The second way is to use a library that allows you to read and write one line at a time. I know that the IJG library can do this, and probably others as well. This is the easy way, but the downside is that the image goes through a decompression/recompression pass and will lose quality and/or be larger.