I have code that add a company logo as a water mark to photos and then saves them back as a jpg. Original images are 35kb, but the new image is 600kb. The watermark is 3kb. 1) why is the new file so large? 2) How can I save these smaller?
' Copy the foreground image into a bitmap.
Dim phototouse As String
phototouse = "C:\inetpub\wwwroot\watermark.png"
Dim picForeground As System.Drawing.Bitmap = New System.Drawing.Bitmap(phototouse)
Dim fg_wid As Integer = picForeground.Width
Dim fg_hgt = picForeground.Height
Dim fg_bm As New Bitmap(fg_wid, fg_hgt)
Using gr As Graphics = Graphics.FromImage(fg_bm)
gr.DrawImage(picForeground, 0, 0, fg_wid, fg_hgt)
' Make the red pixels transparent.
Dim photo As String = photoname
' Make the result bitmap.
Dim picBackground As System.Drawing.Bitmap = New System.Drawing.Bitmap(localfolder & photo)
Dim bg_wid As Integer = picBackground.Width
Dim bg_hgt = picBackground.Height
Dim bg_bm As New Bitmap(bg_wid, bg_hgt)
If cy = 0 And cx = 0 Then
'Need to position photo in far left corner b/c pattern not found
cx = 0 ' Set to zero for logo in left bottom corner, set to bg_wid - 90 for logo in bottom right corner
cy = bg_hgt - 20
'pattern found, adjust to cover the pattern
cx = cx - 2
cy = cy - 11
Using gr As Graphics = Graphics.FromImage(bg_bm)
gr.DrawImage(picBackground, 0, 0, bg_wid, bg_hgt)
' Draw the foreground image on top.
gr.DrawImage(fg_bm, cx, cy, fg_wid, fg_hgt)
' Display the result.
Dim destfile As String = localfolder & photonewname
' We don't need the foreground bitmap any more.