How do i get resized image of external site?
I am trying to display resized images for thumbnail view in my website.
I am creating a page of gallery list where there will be list of thumbnails of开发者_运维技巧 images from external site. i.e if my images are located in xyz.com/images/abc.jpg [600 x 400] then i would like to show its resized form of 150 x 100 in my website.
How much it is effective and good in case of performnance and bandwdith too?
imagecopyresampled will resize an image for ya, there are plenty of examples in the documentation/comments.
The fact that the source image is on another server just means you use a URL when creating the image resource:
$img = imagecreatefromjpg("http://xyz.com/images/abc.jpg");
Store the thumbnail on your server and serve that file on future requests rather than generating it again on each request, otherwise you waste lots of bandwidth and CPU time.
精彩评论