Home >Backend Development >PHP Tutorial >How to output multiple sizes of images in php
<code>http://img.vglook.com/upload/postcover/201605/6966_1462518089.jpg!w480h270</code>
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?
<code>http://img.vglook.com/upload/postcover/201605/6966_1462518089.jpg!w480h270</code>
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