Sub SavePicture (SourceDir As String, PicFilename As String, SaveDir As String)
Try
' Copy the whole image to final dir
File.Copy(SourceDir, PicFilename, SaveDir, PicFilename)
' Make a thumbnail and save it to the \thumbs dir
Dim im As Image
Dim can As Canvas
im.Initialize(SourceDir,PicFilename)
Dim jo As JavaObject
can.Initialize("")
jo = can
' Determine what the height setting should be based on the original size
Dim SetWidth As Double = 150.0
Dim SetHeight As Double
If im.width < 1 Then ' Some pictures will have null values in everything!
SetHeight = SetWidth
Else
Dim SetHeight As Double = (SetWidth / im.Width) * im.Height
End If
jo.RunMethod("setWidth",Array(SetWidth))
jo.RunMethod("setHeight",Array(SetHeight))
can.DrawImage(im,0.0,0.0,SetWidth,SetHeight)
Dim out As OutputStream = File.OpenOutput(SaveDir & "\thumbs", PicFilename, True)
can.snapshot.WriteToStream(out)
out.Close
Catch
Main.LogMessage("Error Saving Picture" & LastException)
End Try
End Sub