2

Here is my problem: i have a rich text lite field, used to store a contact photo. Parameter of this field is: - only allow for thumbnail with an image attachment name (mandatory) = ContactPhoto Parameter of the Rich Text Lite

When the user clicks on it, a standard import dialog box (managed automatically by Notes) is open and all images type can be selected as shown here : ScreenShot of the import dialog box

With the following code, I'm able to check the size of the photo:

Set uidoc=ws.CurrentDocument
Call uidoc.Refresh(True,True)
Set doc=uidoc.Document

oneKB = 1024
PhotoTrouve = False
Forall i In doc.Items
    If i.type = Attachment Then
        Set emb = doc.GetAttachment(i.values(0))
        If emb.source="ContactPhoto" Then
            PhotoTrouve = True
            If emb.filesize > (50 * oneKB) Then
                strError="The size of the photo should be less than 50 Kb." 
            End If
        End If
    End If
End Forall 

If PhotoTrouve= False Then
    strError="Photo is mandatory."                  
End If

But this is not enough. I also need to check if this is well a .jpg file. The problem is that, as this is a thumbnail, its name is ContactPhoto, without any extension and i don't know how to get the original extension of the file selected by the user (seems not to be possible).

So my question is : is it possible to force the standard dialog box of the "thumbnail rich text lite" field in order that it proposes only .jpg extension file type to the user ? How to ?

Or if not, do you know a solution to check that the original file is well a .jpg file ?

Note : even if I name the attachment CPhoto.jpg (instead of ContactPhoto) by example, the user can select all type of images, not only a jpg. The photo is saved in $FILE of the document under the name of CPhoto.jpg but I don't think that the file is finally a real .jpg format. And I absolutely need a jpg image as my final objective is then to export that image in an xml file, with the good format of jpg.

Thanks a lot for your replies and help. Karen

K. Gratiot
  • 31
  • 2

1 Answers1

0

You will have to translate it from C#, but code to check the file contents to see if it is a jpg can be found in this answer to a previous question on this site.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • Is C# usable in Lotus Notes designer ? I don't know how to translate the image in C#, sorry.... – K. Gratiot Jun 30 '17 at 11:45
  • No, C# cannot be used in Domino Designer, but if you read the code I'm sure you can see what it is doing and figure out the equivalent LotusScript code. All it does is read a few bytes from the jpg file and check their values. – Richard Schwartz Jun 30 '17 at 13:44
  • It's just the first four bytes of the only tricky part is that it is dealing with byte reversal for big/little endian conversion, so the code and comments don't look like they match up - but they really do. – Richard Schwartz Jun 30 '17 at 13:49
  • I think I understand what you mean. I have to check if once the thumbnail is stored in the $FILE, i can found the "magic number" of the .jpg file. And so try to translate that code C# into a lotusscript code. Thank you, i will try and keep you posted. – K. Gratiot Jul 04 '17 at 20:55