Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get image size without loading it
Message
De
29/10/2013 04:01:00
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
08/10/2013 08:17:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01584779
Message ID:
01586638
Vues:
65
J'aime (1)
>>That's what I did first, but then that was an early version of this, back in the times when there was never enough disk space. Now I'm reconsidering... though the above link gives some hint to the nature of the JPEG header(s). I was also storing a minimal webpage which would display the picture in a browser object, plus some data (mostly date and time, nothing much). Well, an interesting pastime for, I guess, november, when the weather is... well, you'd call it nice.
>
>You'll find plenty of info here http://www.fileformat.info/index.htm
>eg PNG: http://www.fileformat.info/format/png/corion.htm

OK, here's a version which kind of works for most of the cases (and there are so many of those, it's unbelievable - yet my old faithful ACDSee, from 1998, still reads each one flawlessly):
	Procedure GetJpgSize(tcF)
		Local lcBafer, lnWhere, lnHeight, lnWidth, h
		h=Fopen(tcF,0)
		If Pcount()<2
			o=Createobject("empty")
		Endif
* the FF is first read outside the loop
		lcBafer=Fread(h,8192)

* this is what we are looking for
		Store 0 To lnWidth, lnHeight
		lnWhere=1
		Do While Between(lnWhere, 1, Len(lcBafer)) And Not Between(lnWidth, 257, 8000) And Not Between(lnHeight, 257, 8000);
			and not feof(h)
			lnWhere = At( 0hffC0, lcBafer)
			If lnWhere>0
				lnWhere = lnWhere + 4
				lnHeight = Bitor(Bitlshift(Asc(Subs(lcBafer,lnWhere+1,1)), 8), Asc(Subs(lcBafer,lnWhere+2,1)))
				lnWidth = Bitor(Bitlshift(Asc(Subs(lcBafer,lnWhere+3,1)), 8), Asc(Subs(lcBafer,lnWhere+4,1)))
			Endif
			lcBafer=Substr(lcBafer, lnWhere)
			If Len(lcBafer)<1000 And Not Between(lnWidth, 257, 8000) And Not Between(lnHeight, 257, 8000)
				lcBafer = lcBafer + Fread(h,8192)
			Endif
		Enddo
		Fclose(h)
* some failsafes...
		lnWidth=Evl(lnWidth, 640)
		lnHeight=Evl(lnHeight, 480)
		AddProperty(o, "width", lnWidth)
		AddProperty(o, "height", lnHeight)
		Return o

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform