开发者

JPG / PNG Thumbnail

开发者 https://www.devze.com 2023-04-03 20:28 出处:网络
So let\'s say I have a JPEG file of 4mb~ and I don\'t want to read it all to create a preview. Is there a way to skip reading some cols/rows? I tried for example Irfanview Thumbnails, but that applica

So let's say I have a JPEG file of 4mb~ and I don't want to read it all to create a preview. Is there a way to skip reading some cols/rows? I tried for example Irfanview Thumbnails, but that applications read the entire file first, then creates the thumbnail, so I was thinking of doing a custom app to achieve this.

If I don't care about quality or artifacts, is this possible? The ima开发者_JAVA百科ge resides in local / private network filesystem.


If the JPEG image has an embedded (EXIF) thumbnail, you can read that much faster than reading the whole file. The thumbnail image is usually less than 24K bytes. Typical phones and digital cameras embed a 160x120 image. If this is large enough for your purposes and you're working with photos, then you have a solution. For the case where you don't have an embedded thumbnail or need one at a higher resolution, you will need to read the entire file contents unless it is stored as a progressive image (as mentioned above). The quickest way to generate a thumbnail is to use only the DC values for each MCU and you will end up with a 1/64th image (1/8th in x and y directions). This allows you to skip the expensive DCT and color conversion steps for the entire image.

0

精彩评论

暂无评论...
验证码 换一张
取 消