Consider this function:
Public Function Q1C_CheckJpegImage(ByVal UID_Person As String) As Boolean
Dim Person As ISingleDbObject = Connection.CreateSingle("Person", UID_Person)
Dim ThePhoto As Image
Dim _arr() As Byte
_arr = Person.GetValue("JpegPhoto").Binary
Dim ms As New MemoryStream(_arr)
Try
ThePhoto = Image.FromStream(ms)
Catch ex As Exception
Return True
End Try
If ThePhoto.Width > 400 Or ThePhoto.Height > 400
Return False
End If
Return True
End Function
This can be added as an amendment to a custom OnSaving script like this:
If $JPegPhoto[o]$ <> $JPegPhoto$ Then
If Not Q1C_CheckJpegImage($UID_Person$) Then
Throw New ViException("Photo dimensions too large.")
End If
End If