converting image to all sizes on upload vs resizing on request via php

GROVER.

So I have a platform for users which allows them to upload a fair amount of pictures. At the moment, I have my server resizing and saving all images individually to my CDN (so I can pick the best option in order to reduce load time when a user requests to view it), but it seems very wasteful in regards to server storage.

The images are being converted into resolutions of 1200px, 500px, 140px, 40px and 24px.

What I'm wondering is, would it be more efficient to just save the file at 1200px, then serve it via PHP at the requested size using something like ImageMagick? Would there be any major trade-offs and if so, is it worth it?

What I'm doing right now:

https://v1x-3.hbcdn.net/user/filename-500x500.jpg

An example of what I could do:

https://v1x-3.hbcdn.net/image.php?type=user&file=filename&resolution=500

Cheers.

cetver

No it's not, because:

  1. you have a small number of sizes

  2. if you will not use caching (image generation on first request only) you can DDOS yourself (image processing its a cpu affected process)

  3. have to do extra work if will use CDN like Cloudflare for HTTP-caching

It makes sense if you have a lot sizes of images, for example, API that supports multiple Andoid/IOS devices, meaning iphone 3 supports 320x320 image only and if you dont have users with such device, your server never creates such image.

Advice:

During image generation, use optimization it reduces image size with imperceptible loss of quality.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Resizing a BLOB image in PHP before sending to client

分類Dev

Changing php.ini upload sizes in a safe, minimal way

分類Dev

php image upload error in Chrome

分類Dev

Laravel Multiple Image Upload via API

分類Dev

upload an image file to sharepoint via api graph

分類Dev

Using RestSharp to upload an image via Etsy API

分類Dev

Add all sizes of image asset in Android Studio with a PDF or Vector file

分類Dev

Php image upload : Changing image names

分類Dev

How to export image from cropit to php for upload?

分類Dev

Php multiple image upload processing error

分類Dev

PHP - get video and image dimensions on upload

分類Dev

Upload single image file to FTP using PHP

分類Dev

upload multiple bit map image to php server

分類Dev

Magmi Image Upload Remore Url from PHP

分類Dev

How do I upload an image using PHP?

分類Dev

Trying to upload image from iPhone to server with PHP

分類Dev

Resizing Vaadin Image

分類Dev

Faster image resizing

分類Dev

resizing an image in tkinter

分類Dev

how to remove image from filelist and upload it on server using api request?

分類Dev

TabBarItems and setting their image sizes?

分類Dev

iPhone Image sizes

分類Dev

How to check/fix image rotation before upload image using PHP

分類Dev

get image width during image upload ajax php

分類Dev

Mysql print all rows via php

分類Dev

How to upload an image to Quill rich text editor via quil-image-uploader module

分類Dev

Resizing subview containing image in UIStackView

分類Dev

Resizing clipped part of the image with CSS

分類Dev

How to Remove Image Resizing in HTML