Avatar of SkipFire
SkipFire
 asked on

Convert TIF to JPG

I think the following code "should" work, the output is about the right size for a jpg, but it is not coming out as a valid jpg image file.  I have tried saving to disk as well.  Please either tell me how to fix this code, or give me a good sample that does not use third-party objects.  I am working in .NET 2.0.  I have verified permissions are NOT a problem.  C# code solutions are fine as well.  ---page editor please do not move this to VB.NET.
 
        Dim originalimage As System.Drawing.Image = System.Drawing.Image.FromFile("C:\Test.tif")
        Dim stm As New System.IO.MemoryStream
        Call originalimage.Save(stm, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim bytes(stm.Length) As Byte
        Call stm.Read(bytes, 0, stm.Length - 1)
        Response.ContentType = "image/jpeg"
        Call Response.Clear()
        Call Response.BinaryWrite(bytes)
        Call originalimage.Dispose()
        originalimage = Nothing
.NET Programming

Avatar of undefined
Last Comment
Jens Fiederer

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jens Fiederer

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SkipFire

ASKER
Beautiful - it worked great.
Jens Fiederer

Thanks.  Short and sweet exchange!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck