Writing EXIF file properties

J

Joaquin Corchero

Hi, I have this code which it should change the EXIF file properties of
images, but there is something that doesn't work, any ideas???

Private Sub ShowBitMapProp(ByVal sFile As String)

Dim sExt = LCase(sFile).Substring(sFile.LastIndexOf("."))

If sExt = ".jpg" Or sExt = ".gif" Then

Response.Write("ShowBitMapProp<br>" & vbCrLf)

Dim oBitmap As Image = Image.FromFile(sFile)

'Dim oProba As Image = Image.FromFile(sFile)

'oProba.Dispose()

'oBitmap = oProba.Clone

'Dim oBitmap As Bitmap = New Bitmap(sFile)

'Dim ooBitmap As Birmap = oBitmap.FromFile(sFile)

Dim iConta As Integer

Response.Write("Number of properties: " &
oBitmap.PropertyItems.Length.ToString & "<br>" & vbCrLf)

Dim oPrps() As System.Drawing.Imaging.PropertyItem

Dim oPrp As System.Drawing.Imaging.PropertyItem

oPrps = oBitmap.PropertyItems

Dim bByte() As Byte

Dim bConv As System.BitConverter

Dim utf As New System.Text.UTF7Encoding

Dim bNewValue() As Byte

Dim iCont As Integer

Dim sProba As String = "Joaquin"

For iConta = 0 To oPrps.Length

oPrp = oPrps(iConta)

'Response.Write(oBitmap.PropertyIdList.GetValue(iConta).ToString & " Idlist
" & iConta & "<br>" & vbCrLf)

If oPrp.Id.ToString = "40091" Or oPrp.Id.ToString = "40092" Or _

oPrp.Id.ToString = "40093" Or oPrp.Id.ToString = "40094" Or _

oPrp.Id.ToString = "40095" Then

Response.Write(oPrp.Id & "<br>")

bByte = oPrp.Value

Try

Response.Write("Old Value: " & utf.GetString(bByte) & "; ")

bNewValue = utf.GetBytes(utf.GetString(bByte))

bNewValue = utf.GetBytes("Joaquin")

oPrp.Id = oPrp.Id

oPrp.Type = oPrp.Type

oPrp.Len = System.Text.ASCIIEncoding.Unicode.GetBytes(sProba).Length

oPrp.Value = System.Text.ASCIIEncoding.Unicode.GetBytes(sProba)

oBitmap.SetPropertyItem(oPrp)

Catch

Response.Write(Err.Description & " Error<br>")

End Try

End If

'40091: Title

'40092: Comments

'40093: Author

'40094: Keywords

'40095: Subject

Next

Try

'File.Delete(sFile)

oBitmap.Save(sFile)

Catch

Response.Write(Err.Description & " Error 2 <br>")

End Try

End If

End Sub



Thank you for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top