Can I dynamically invoke images of different sizes on our website?

Source: Internet
Author: User
The page may be in different locations, need different sizes of pictures

For example, published an article, upload the title image, generated a original 580*700 and a map of the 100*100

If I want to call this image on the homepage, the size is 200*240, how to do, is the 580*700 of the original limit width of 200? (Load the original effect of the performance bar)

or upload pictures, the need to upload all the dimensions of the map (this is not very good, such as my home page or other pages used in different sizes, not to upload a lot of different size of the picture)

Is there any good solution?


Reply to discussion (solution)

Our site's approach is to send a map to generate seven different size of the map to store it up. These seven sheets are set according to the requirements.

Then call the corresponding size picture in the corresponding position


If the width height of the img tag is forcibly scaled, the page will be jammed.

Generally reduced to a variety of sizes, do not think this is omitted storage space
Compare the 100k to 10k reduction before and after the traffic, set 10 pages to use this picture, 10,000 people visit each day, are full of these 10 pages, and assume that the client cache enough for a day of browsing (the same day refresh the page does not re-transfer pictures)

100k*10*10000*30=300g/Month
After shrinking, it's natural to divide by 10,30g/months.

This is only a picture for 10 pages, not counting the page refresh, more pictures, More page calls (Don't underestimate "reprint" AH) situation
So the larger the station, the more you want to reduce the number of bytes of pictures, of course, as needed, not blindly only to save traffic, but also to take into account the quality of service

As for the image station to display the original picture that is another matter, that is from the quality of service considerations, and the original is rarely repeated on multiple pages display

That's right upstairs. Storage space is much cheaper than traffic/bandwidth ....

Well, correct the above error, if the same picture (the same URL), the client uses the cache and already exist this diagram, no matter how many pages, no repetition, but different browsers, or not necessary

The page may be in different locations, need different sizes of pictures

For example, published an article, upload the title image, generated a original 580*700 and a map of the 100*100

If I want to call this image on the homepage, the size is 200*240, how to do, is the 580*700 of the original limit width of 200? (Load the original effect of the performance bar)

or upload pictures, the need to upload all the dimensions of the map (this is not very good, such as my home page or other pages used in different sizes, not to upload a lot of different size of the picture)

Is there any good solution?
How is the database structure designed? There are seven different size title graphs, seven fields are stored?


The page may be in different locations, need different sizes of pictures

For example, published an article, upload the title image, generated a original 580*700 and a map of the 100*100

If I want to call this image on the homepage, the size is 200*240, how to do, is the 580*700 of the original limit width of 200? (Load the original effect of the performance bar)

or upload pictures, the need to upload all the dimensions of the map (this is not very good, such as my home page or other pages used in different sizes, not to upload a lot of different size of the picture)

Is there any good solution?
How is the database structure designed? There are seven different size title graphs, seven fields are stored?

Let me give you an example.

123.jpg than film

Database Storage 123.jpg

Seven different sizes of pictures are a_123.jpg b_123.jpg ...

Only one in the database ..... When the program calls, add the prefix of the size corresponding.

My practice is to use PHP??? The size of the film, for example

I?? A.jpg is the original, each use? Different sizes to the service, the service??? ??? With img.php The whole original?? The size of the customer requirements, after the completion of the whole, directly to the customer terminal,????? The film is not stored directly on the service,?? Do you have a good practice? And not the heart flow??, but he?? CPU capacity of the server.

Good thinking, learning under

My practice is to use PHP??? The size of the film, for example

I?? A.jpg is the original, each use? Different sizes to the service, the service??? ??? With img.php The whole original?? The size of the customer requirements, after the completion of the whole, directly to the customer terminal,????? The film is not stored directly on the service,?? Do you have a good practice? And not the heart flow??, but he?? CPU capacity of the server.

What is the response speed of the file and the direct reading?


My practice is to use PHP??? The size of the film, for example

I?? A.jpg is the original, each use? Different sizes to the service, the service??? ??? With img.php The whole original?? The size of the customer requirements, after the completion of the whole, directly to the customer terminal,????? The film is not stored directly on the service,?? Do you have a good practice? And not the heart flow??, but he?? CPU capacity of the server.

What is the response speed of the file and the direct reading? More than direct? The size of the film is slower, the reason is as follows: directly to take the saved? Tablets only need to consume????, and I do? Need CPU first? The size of the whole piece is then out to the client side, so there is one more step? How much slower is the CPU speed of the server.



My practice is to use PHP??? The size of the film, for example

I?? A.jpg is the original, each use? Different sizes to the service, the service??? ??? With img.php The whole original?? The size of the customer requirements, after the completion of the whole, directly to the customer terminal,????? The film is not stored directly on the service,?? Do you have a good practice? And not the heart flow??, but he?? CPU capacity of the server.

What is the response speed of the file and the direct reading? More than direct? The size of the film is slower, the reason is as follows: directly to take the saved? Tablets only need to consume????, and I do? Need CPU first? The size of the whole piece is then out to the client side, so there is one more step? How much slower is the CPU speed of the server.

Yes, but I didn't think of that before.

There should be places to use, less commonly used pictures and the like.




My practice is to use PHP??? The size of the film, for example

I?? A.jpg is the original, each use? Different sizes to the service, the service??? ??? With img.php The whole original?? The size of the customer requirements, after the completion of the whole, directly to the customer terminal,????? The film is not stored directly on the service,?? Do you have a good practice? And not the heart flow??, but he?? CPU capacity of the server.

What is the response speed of the file and the direct reading? More than direct? The size of the film is slower, the reason is as follows: directly to take the saved? Tablets only need to consume????, and I do? Need CPU first? The size of the whole piece is then out to the client side, so there is one more step? How much slower is the CPU speed of the server.

Yes, but I didn't think of that before.

There should be a place to use, not commonly used pictures and the like?? How good is the practice? It is only necessary to keep it in the service of the server. It is not necessary to test the number of???, shortage of the external CPU??




My practice is to use PHP??? The size of the film, for example

I?? A.jpg is the original, each use? Different sizes to the service, the service??? ??? With img.php The whole original?? The size of the customer requirements, after the completion of the whole, directly to the customer terminal,????? The film is not stored directly on the service,?? Do you have a good practice? And not the heart flow??, but he?? CPU capacity of the server.

What is the response speed of the file and the direct reading? More than direct? The size of the film is slower, the reason is as follows: directly to take the saved? Tablets only need to consume????, and I do? Need CPU first? The size of the whole piece is then out to the client side, so there is one more step? How much slower is the CPU speed of the server.

Yes, but I didn't think of that before.

There should be places to use, less commonly used pictures and the like.

I have also thought about this, for example, in the loop output article list, every output of an article to call the img.php output thumbnail
Web sites can become slow if you visit a large number of sites


The page may be in different locations, need different sizes of pictures

For example, published an article, upload the title image, generated a original 580*700 and a map of the 100*100

If I want to call this image on the homepage, the size is 200*240, how to do, is the 580*700 of the original limit width of 200? (Load the original effect of the performance bar)

or upload pictures, the need to upload all the dimensions of the map (this is not very good, such as my home page or other pages used in different sizes, not to upload a lot of different size of the picture)

Is there any good solution?
How is the database structure designed? There are seven different size title graphs, seven fields are stored?

This is a long time, will produce a lot of redundant images, some pictures on the site is always not used, but will always exist on the server occupied space

A large number of visits or honestly do static files it
Like # # Practice, every time you upload a picture to do the conversion, save several fixed-size pictures?? Yi Lao
Then call the appropriate size on different pages, although not necessarily exactly the same as the page requirements, but with the slight change in HTML Width/heigh have little effect?? Yong Yat

A bigger station and a CDN cache.

Dynamically generated pictures on the server pressure is too large, or directly generate a variety of different formats good, after all, hard disk is not valuable.

If you are afraid of too many pictures, stored by the resolution of the different folders, the next time to clean up and delete

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.