Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Utility to discover type of Image & its real file extens
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01228930
Message ID:
01228987
Vues:
20
This message has been marked as the solution to the initial question of the thread.
>Is there a utility on this forum in which I can discover a file's real image type, such as JPG, PNG, etc.? I want to determine what type of Image file each file is and then return the File Extension, such as "JPG", "PNG", etc.
Function filetype
  Lparameters lcData
  Local lcReturn,lcContents
  If Pcount()=0 Or Vartype(lcData)#'C'
    lcReturn=''
  Else
    If Adir(laDummy,lcData)>0 && File
      lcContents=Filetostr(lcData)
    Else && Memory variabøe
      lcContents=lcData
    Endif
    Do Case
      Case Len(lcContents)<4
        lcReturn=''
      Case Left(lcContents,3)=Chr(0xFF)+Chr(0xD8)+Chr(0xFF)
        lcReturn='JPG'
      Case Left(lcContents,3)='GIF'
        lcReturn='GIF'
      Case Substr(lcContents,42,3)='EMF'
        lcReturn='EMF'
      Case Left(lcContents,4)=Chr(0xD7)+Chr(0xCD)+Chr(0xC6)+Chr(0x9A)
        lcReturn='WMF'
      Case Left(lcContents,4)=Chr(0x4D)+Chr(0x4D)+Chr(0x00)+Chr(0x2A)
        lcReturn='TIF'
      Case Left(lcContents,4)=Chr(0x89)+'PNG'
        lcReturn='PNG'
      Case Left(lcContents,2)='BM'
        lcReturn='BMP'
      Case Left(lcContents,3)='CWS' And Asc(Substr(lcContents,4,1))<16
        lcReturn='SWF'
      Case Left(lcContents,3)='FWS'  And Asc(Substr(lcContents,4,1))<16
        lcReturn='SWF'
      Otherwise
        lcReturn=''
    Endcase
  Endif
  Return lcReturn
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform