I can't figure this one out. From as far as I can tell in the code, this should work, but it's not. Basically all I'm doing is copying an image to a new folder. Then taking that image, resizing it in memory, then resaving the file with the changes. The reason I want to resave the file instead of deleting the old file and saving the new file, is because I need to maintain the GPS data in the property details. What this code is producing is simply a larger file size (the expected file size at the new resolution), but no actual change to the resolution/dimensions. Microsoft Picture Manager can do it, so I know it's possible. When I stop the code at the fs.Dispose() line and evaluate the properties in myImage and fs, they both indicate the new resolution. Indeed, if I change the save file name and create a new file, it creates it with the correct resolution/dimensions, but not the property details. Thoughts?
Code:
System.IO.File.Copy(path, TextBox2.Text & "\Tmp\" & RandomStrTxt & ".jpg", True)
Dim fs As FileStream = New FileStream(TextBox2.Text & "\Tmp\" & RandomStrTxt & ".jpg", FileMode.OpenOrCreate)
Dim myImage As Image = ResizeImage(Image.FromStream(fs), New Size(picWidth, picHight))
myImage.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg)
fs.Dispose()