如何在网页中显示ziped图像? [英] How do I display ziped images in a web page?

查看:103
本文介绍了如何在网页中显示ziped图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个小项目,我想自动显示压缩文件夹中的图像而不实际链接每个图像。在这种情况下,我还会更改其他zip文件夹。系统应该能够访问该新文件夹中的图像。那么我该怎么办?

解决方案

首先,压缩图像毫无意义。有损图像压缩算法(如JPEG)在图像上比ZIP更有效。



在显示之前解压缩。一次飞行的方法取决于您使用的服务器端技术。一个常见的部分是:表示资源的脚本应编写具有正确内容类型的HTTP标头。例如:

内容类型:image / jpeg 



请参阅:

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields [ ^ ],

http://en.wikipedia.org/wiki/Internet_media_type [ ^ ]。



基本上,您可以获得图像请求(例如,很简单,图像名称可能是您的URL参数可以从URL中提取)。您的代码获取ZIP文件,将文件内容提取到流中(无需在磁盘上创建文件),然后写入HTTP标题Content-Type,后跟此流的内容。



如果您不使用任何服务器端,请解压缩文件并存储然后解压缩到您的服务器上。



-SA

I am doing a small project and I want to display images from a zipped folder automatically without actually linking each images. In this case,I would also change other zip folder.The system should be able to access images from that new folder. So how do I do this?

解决方案

First of all, zipping of images makes little sense. Lossy image compression algorithms, such as JPEG, are much more efficient on images than ZIP.

Unzip it before showing. The way to do it one the fly depends on the server-side technology you use. One common part is: your script representing the resource should write an HTTP header with correct content-type. For example:

Content-Type: image/jpeg


Please see:
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields[^],
http://en.wikipedia.org/wiki/Internet_media_type[^].

Basically, you get request for the image (say, quite simply, image name could be a URL parameter you can extract from URL). Your code takes the ZIP file, extracts the file content into the stream (no need to create a file on disk), then writes the HTTP header "Content-Type" followed by the content of this stream.

If you don't use any server-side, unzip the files and store then unzipped on your server.

—SA


这篇关于如何在网页中显示ziped图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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