Calimero
Calimero

Reputation: 1074

Load external images efficiency

I would like to know a most efficient way to load external images to my website.

For example: My website's url is "www.mydomain.com". The external image is http://www.myimagedomain.com/image.jpg. The most common way is to write a simple html image-tag like <img src="http://www.myimagedomain.com/image.jpg" />.

The problem is, if the requested image is very large (8000x6000 pixel) but I want to show this picture as a thumbnail/preview like 200x200 pixel, e.g on mobile devices.

Based on this information I wrote a little ashx (c#) handler that downloads the requested image and resizes it to a given weight/height parameters, like this:

<img src="http://www.mydomain.com/img.ashx?imageUrl=http://www.myimagedomain.com/image.jpg&w=200&h=200" />

Now there is another problem, because the httphandler always downloads the requested image, on-the-fly.

My new approach is to generate a based64 string from the resized image and save this in a database once?! Would you recommend this or is there another way to eliminated the download problem? Maybe someone know how google-image-search prevents this problem?

I don't want to save the external images on my own server...

Upvotes: 1

Views: 173

Answers (1)

Giedrius
Giedrius

Reputation: 8540

I would suggest to use image resizer library, it solves much of what you need in efficient way - caching included: http://www.nuget.org/packages/ImageResizer/

I think google caches image thumbnails on its servers for search.

Upvotes: 1

Related Questions