渐进式JPEG的完整缩略图需要多少个字节? [英] How many bytes are needed for a complete thumbnail of a progressive JPEG?

查看:73
本文介绍了渐进式JPEG的完整缩略图需要多少个字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个上传器,该上传器分两个步骤上传渐进式文件:

I am trying to build an uploader which uploads progressive files in two steps:

  1. 上传最小字节数以创建缩略图(0-10%)
  2. 上传缩略图的其余字节. (11%-100%)

我要这样做是为了使缩略图更早可用,而不必上传单独的缩略图. 拍摄使用jpegtran -copy all -progressive -outfile progressive.jpg original.jpg创建的图像(3426398字节),然后使用dd if=progressive.jpg of=thumb.jpg bs=1 count=350000拍摄前350000字节,我得到了可以使用的缩略图.

I want to do this to have thumbnails available earlier without having to upload a seperate thumbnail. Taking an image (3426398 Byte) which was created with jpegtran -copy all -progressive -outfile progressive.jpg original.jpg and then taking the first 350000 bytes with dd if=progressive.jpg of=thumb.jpg bs=1 count=350000 I got a thumbnail which works.

  • Original: https://dl.dropbox.com/u/5910/thumbtest/progressive.jpg
  • Thumbnail: https://dl.dropbox.com/u/5910/thumbtest/thumb.jpg

有没有一种方法可以找出我必须传输多少字节才能获得所有行都可用的图像?这样只会失去图像质量吗?

Is there a way to find out how many bytes I have to transfer in order to get an image where all lines are available? Thus only losing image quality?

推荐答案

逐行JPEG图像由一系列扫描"组成.每次扫描为每个MCU块提供更多的信息(更多的A/C系数).第一次扫描通常只是每个MCU的DC值.这恰好是为您提供1/8尺寸缩略图的理想信息.

A progressive JPEG image is made up of a series of "Scans". Each Scan provides progressively more information for each MCU block (more A/C coefficients). The first scan is usually just the DC values for each MCU. This happens to be the perfect amount of information to get you a 1/8th sized thumbnail image.

在JPEG文件中,每次扫描均以FFDA的SOS(扫描开始)标记开始.为了知道完全保留第一次扫描所需的数据量,只需搜索文件数据以查找第二次扫描的开始(第二个FFDA标记),您便可以找到答案.由于存在标记字节规则,因此2字节序列FF DA只能是SOS标记.需要对值FF和DA进行编码的压缩数据必须被编码为FF 00 DA.

In the JPEG file, each scan starts with a SOS (start of scan) marker of FFDA. In order to know how much data is needed to completely hold the first scan, simply search the file data for the start of the second scan (the second FFDA marker) and you have your answer. Because of the marker byte rules, the 2 byte sequence FF DA cannot be anything but the SOS marker. Compressed data which needs to encode the value FF followed by DA would have to be encoded as FF 00 DA.

这篇关于渐进式JPEG的完整缩略图需要多少个字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆