troubleshooting Question

Convert TIF to JPG

Avatar of SkipFire
SkipFire asked on
.NET Programming
3 Comments1 Solution399 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Jens Fiederer
Test Developer/Validator

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros