Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting file type
Message
De
14/08/2005 09:47:11
 
 
À
14/08/2005 09:20:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
01040691
Message ID:
01040775
Vues:
15
Malcolm,

yes, I read it. I checked a lot of JPG files, and I see it was actually a typo in my message, the 3-4 first bytes are always the same. Here's the updated function including BMP also:
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'
      Otherwise 
        lcReturn=''
    EndCase 
  EndIf 
Return lcReturn
>Tore,
>
>Thanks for the filetype() function. I added "BM" for "BMP". Also, did you see Michel's post on JPG detection? It looks like he found JPG files that used a shorter version of your JPG detection string, specifically hex "FFD8" vs. your longer header constant.
>
>Malcolm
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform