Results 1 to 12 of 12

Thread: how do you compress an image?

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    how do you compress an image?

    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.

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: how do you compress an image?

    Quote Originally Posted by System_Error
    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,

    Here's a link about how to compress an Image;

    http://msdn.microsoft.com/library/de...gecompress.asp

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: how do you compress an image?

    Are you sure that's VB.NET?

  4. #4
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: how do you compress an image?

    Quote Originally Posted by System_Error
    Are you sure that's VB.NET?
    Hi,

    sorry I put the wrong link into your thread.

    Here's the one I should putted into your thread.

    http://www.codeproject.com/cs/media/MPEGFunction.asp

    Must be the better one.

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: how do you compress an image?

    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...

  6. #6

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: how do you compress an image?

    Quote Originally Posted by gigemboy
    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...

    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?

  7. #7
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: how do you compress an image?

    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

  8. #8
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: how do you compress an image?

    yea i remeber this post, it was a good one by the way

  9. #9

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: how do you compress an image?

    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:

    Code:
    bAfter.Image.Save(output_location, jpegCodec, encoderParams)
    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).

    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!

  10. #10
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: how do you compress an image?

    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...
    Last edited by gigemboy; Jun 3rd, 2006 at 12:00 PM.

  11. #11
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: how do you compress an image?

    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?

  12. #12
    Hyperactive Member OMITT3D's Avatar
    Join Date
    Mar 2006
    Posts
    368

    Re: how do you compress an image?

    http://www.vbforums.com/showpost.php...41&postcount=2

    What are the imports needed for that?


    edit..nvm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width