How to output multiple sizes of images in php

WBOY
Release: 2016-07-06 13:54:09
Original
1069 people have browsed it

<code>http://img.vglook.com/upload/postcover/201605/6966_1462518089.jpg!w480h270</code>
Copy after login
Copy after login

As the picture above is a width 480 height 270 picture, remove the suffix !w480h270 to access the original picture.

Question:
1. How is this kind of image usually stored on the server? Is it just the original image?
2. Adding the suffix !w480h270 can generate corresponding thumbnails. How are thumbnails generally stored and in what form?
3. Generally, when you visit for the first time, do you need to determine !w480h270 whether there is a cache for images in this format? Then if there is a cache, the cache is read, and if there is no cache, the cache is generated through processing?

Reply content:

<code>http://img.vglook.com/upload/postcover/201605/6966_1462518089.jpg!w480h270</code>
Copy after login
Copy after login

As the picture above is a width 480 height 270 picture, remove the suffix !w480h270 to access the original picture.

Question:
1. How is this kind of image usually stored on the server? Is it just the original image?
2. Adding the suffix !w480h270 can generate corresponding thumbnails. How are thumbnails generally stored and in what form?
3. Generally, when you visit for the first time, do you need to determine !w480h270 whether there is a cache for images in this format? Then if there is a cache, the cache is read, and if there is no cache, the cache is generated through processing?

You can go to github to view similar libraries, for example: https://github.com/AlloVince/EvaThumber

However, it is actually very inappropriate for PHP to do such a thing. Let's leave it to CDN.

That picture of yours was taken again from the clouds. If you want to implement it yourself
1. The server stores the original image, and the image is stored in blocks, which is not actually a file.
2. Thumbnails are not stored, they are all cached by CDN.
3. Right. When you visit, you first check whether the CDN has a cache, then whether the upper-layer node has a cache, and finally the original image is used to generate the cache.

Taobao also follows this logic. There is an article introducing Taobao pictures. You can go find it

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!