Is there a way I can compress an image in VB.NET? If someone can point me to a tutorial or anything useful that would be great.
Printable View
Is there a way I can compress an image in VB.NET? If someone can point me to a tutorial or anything useful that would be great.
Hi,Quote:
Originally Posted by System_Error
Here's a link about how to compress an Image;
http://msdn.microsoft.com/library/de...gecompress.asp
Hope it helps,
sparrow1
Are you sure that's VB.NET?
Hi,Quote:
Originally Posted by System_Error
sorry I put the wrong link into your thread. :blush:
Here's the one I should putted into your thread.
http://www.codeproject.com/cs/media/MPEGFunction.asp
Must be the better one. :thumb:
Wkr,
sparrow1
Compress an image into what? From what initial type to what compressed type? Do you mean BMP to JPG, or what? A little more info would be needed in order to give a more precise and informative answer, as there are numerous image types...
Quote:
Originally Posted by gigemboy
Like the quality of the image. If you have photoshop, before you save an image, you can select the 'quality' which reduces size or increases size.
That better?
But each file format would have its own compression scheme. I believe you are referring to JPEGs, which allows you to change the compression level. I had replied a while back in a post about a way to go about doing this, and found it in the thread link below:
http://www.vbforums.com/showthread.php?t=370585
The method should allow you to specify a number from 1-100 to specify the amount of compression/quality when saving images as JPEGs
yea i remeber this post, it was a good one by the way :)
Thanks gigem! Sorry for the late reply, but I've been really busy lately. I'm working with the comperssion right now and I have a few more questions.
The following like of code:
Is there a way I can create a new bitmap with those parameters instead of saving it right away? (I want to provide a preview and the ability to select other options before saving).Code:bAfter.Image.Save(output_location, jpegCodec, encoderParams)
I can't find any bitmap constructor that takes that parameter. (This will be previewed in a picturebox)
One more thing: If I have different image types and I want to compress them, then do I just change the following line?:
Code:GetEncoderInfo("image/jpeg")
Thanks in advanced for any help you may give!
No, that code was just for the JPEG codec. JPEG image types allow you to change the compression percentage. Other types do not allow this. BMP's are uncompressed, GIF's dont have "compression", just different pallettes I believe (2-bit, 4-bit, 8-bit, etc). Thats why I was saying that each image type would be different, because it would matter on the image type that you are trying to work on.
In regards to your question about giving a preview, you can just run the code, saving it to some temp file, then load that temp file right back into a picturebox to see the preview. Just a quick solution using the code provided...
I have a bunch of images off a camera with HUGE resolution is there a way to change the resolution on all of them to say 800x600 thus reducing the image size from 2mbs to something around 100 kbs?
http://www.vbforums.com/showpost.php...41&postcount=2
What are the imports needed for that?
edit..nvm