Is it possible to reduce the file size of an image when the user uploads it into a sql server image field.
i.e Crush it from 500K to less.
Regards,
RGHi,
If you just want to reduce the file size but keep the same content, you could ZIP it after uploading it.
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
Or, if you want to reduce the physical image dimensions, you could make a thumbnail.
http://www.csharp-station.com/Articles/Thumbnails.aspx
Or both!
A.|||Zipping won't help much. Most image types that I've used are already compressed and zipping them gets you very little. Make a thumbnail or use an image processing component to reduce the resolution.|||Thanks Guys,
The user uploads the pic which is then saved to an image field as the full image; as well as a Thumnail made and stored in another image field.
The images are then available through the page.
The thumnail is fine but the full image needs sometimes to be compressed further.
I'll take a look at image processing components but is there now easier way to do this?
Should I be storing images in SQL server anyway, some people say not??
Regards,
RG|||::The thumnail is fine but the full image needs sometimes to be compressed further.
The bad thing with thisis that unless the "image" is an uncompressed bitmap there basically is not too much you can compress out.
::I'll take a look at image processing components but is there now easier way to do this?
No. You need to change the image to compress it further, or you need to change the format of the image (like bitmap to jpg).
::Should I be storing images in SQL server anyway, some people say not??
Some people will also gladly tell you to kill yourself. Will you follow their advice, too?
Storing images in SQL Serverhas advantages and disadvantages. Disads are that SQL Server storage is more costly (in hosting), that operformance is lower (The file system IS faster) unless you manage to pull off some caching (not hard). Advantages are that you can use relational integrity, stuff like cascading delete etc. - basically it is pretty hard to accumulate garbage somewhere.|||That question is one of those which people always debate! Putting it in the database you gain referential integrity, but for much larger files you'll probably lose performance. For small stuff, putting them in the database is fine IMHO, disk is cheap and it keeps things tidy.
A.
No comments:
Post a Comment