ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

WIA:FABRIQUER TOUTES LES VIGNETTES DES PHOTOS D'UN REPERTOIRE   



L'auteur

ybenam
Algérie Algérie
Membre Simple
# 0000002080
enregistré le 21/04/2008


Fiche personnelle


Note des membres
pas de note

Contributions > 09 - Automation

WIA:FABRIQUER TOUTES LES VIGNETTES DES PHOTOS D'UN REPERTOIRE
# 0000000614
ajouté le 11/06/2008 10:56:14 et modifié le 11/06/2008
consulté 8273 fois
Niveau débutant

Version(s) Foxpro :
VFP 6.0

Description
Faisant suite à mon article :
http://www.atoutfox.org/articles.asp?ACTION=FCONSULTER&ID=0000000569
Automation windows image acquisition WIA
ce programme génère des vignettes de photos d'un répertoire (JPG,BMP,GIF,TIFF,PNG) aux dimensions voulues avec préservation de
ratio (offre une bonne lecture de la vignette sans déformation).
Les vignettes seront produites à volonté dans un répertoire(c:\ythumb) ,le type est JPG.
Le résultat est visualisé à la fin (faites dérouler). Amicalement.
Code source :
*B.Yousfi benameuryousfi1@Gmail.com
*créer de vignettes d'un répertoire de photos bmp,jpg,gif,png,tiff avec WIA
*dimensions max des vignettes =100x100 px (on peut changer) avec préservation ratio
*Toutes les miniatures ici seront du type JPG
*Si photos identiques,le programme sort erreur......ignorer
yrep=getdir()
if empty(yrep)
return
endi

set defa to (yrep)
if directory("c:\ythumb")
dele file c:\ythumb\*.*   &&nettoyer le répertoire
else
mkdir c:\ythumb           &&créer
endi


dim1=100
dim2=100
&&les photos jpg
gnbre1=adir(gabase,"*.jpg")
if gnbre1 >0
for i=1 to gnbre1
ximage=(yrep)+gabase(i,1)
xthumb="C:\ythumb\"+juststem(gabase(i,1))+"_thumb.jpg"
do ythumb
endfor
endi
************
&&photos bmp
gnbre1=adir(gabase,"*.bmp")
if gnbre1 >0
for i=1 to gnbre1
ximage=(yrep)+gabase(i,1)
xthumb="C:\ythumb\"+juststem(gabase(i,1))+"_thumb.jpg"
do ythumb
endfor
endi

&&photos gif
*************
gnbre1=adir(gabase,"*.gif")
if gnbre1 >0
for i=1 to gnbre1
ximage=(yrep)+gabase(i,1)
xthumb="C:\ythumb\"+juststem(gabase(i,1))+"_thumb.jpg"
do ythumb
endfor
endi
*************
&&photos png
gnbre1=adir(gabase,"*.png")
if gnbre1 >0
for i=1 to gnbre1
ximage=(yrep)+gabase(i,1)
xthumb="C:\ythumb\"+juststem(gabase(i,1))+"_thumb.jpg"
do ythumb
endfor
endi
*****************************
&&photos tiff
gnbre1=adir(gabase,"*.tiff")
if gnbre1 >0
for i=1 to gnbre1
ximage=(yrep)+gabase(i,1)
xthumb="C:\ythumb\"+juststem(gabase(i,1))+"_thumb.jpg"
do ythumb
endfor
endi
*****************************
&&visualiser
set defa to c:\ythumb
gnbre=adir(gabase,"*.jpg")
if gnbre>0
afile=gabase(1,1)
DECLARE INTEGER ShellExecute IN shell32.dll ;
  INTEGER hndWin, STRING cAction, STRING cFileName, ;
  STRING cParams, STRING cDir, INTEGER nShowWin

ShellExecute(0,"open",afile,"","",1)
endi

************end of main*****************
&&les vignettes sont créées avec préservation ratio..maximumwidth et maximumheight ET NE SONT PAS AUX DIMENSIONS EXACTES PRESCRITES.

procedure ythumb
Img = CreateObject("WIA.ImageFile")
IP = CreateObject("WIA.ImageProcess")
Img.LoadFile(ximage)
IP.Filters.Add(IP.FilterInfos("Scale").FilterID)
IP.Filters(1).Properties("MaximumWidth")  = dim1
IP.Filters(1).Properties("MaximumHeight") = dim2
Img = IP.Apply(Img)
Img.SaveFile(xthumb)

Commentaires
le 11/06/2008, Mike Gagnon a écrit :
deja vu ici
http://www.atoutfox.com/articles.asp?ACTION=FCONSULTER&ID=0000000080

le 11/06/2008, ybenam a écrit :
Merci Mike !
Tous les chemins mèneraient peut être à WIA... !
Ma procédure ythumb (en bas du programme) est prise de WIAaut.chm le SDK en la matière-Chapitre " How to use the filters-Scale filter-resize an image".
En effet,c'est exactement celle citée dans ton ton article:
http://www.atoutfox.com/articles.asp?ACTION=FCONSULTER&ID=0000000080
Amicalement !


Publicité

Les pubs en cours :

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3