lights Posted February 11, 2007 Share Posted February 11, 2007 I need to get the properties of an image. I want to sort images in different directories according to size. By size i mean the width and height in pixels, like 120x120. It's not possible to use FileGetSize() because pictures with the same width and height can have different file sizes. I don't want to open the files one by one and use a pixel function to get it's size Link to comment Share on other sites More sharing options...
Will66 Posted February 11, 2007 Share Posted February 11, 2007 search "image_get_info.au3" Link to comment Share on other sites More sharing options...
lights Posted February 11, 2007 Author Share Posted February 11, 2007 Thank you very much, now I just gotta make it work Link to comment Share on other sites More sharing options...
olivertwistcoder Posted March 21, 2008 Share Posted March 21, 2008 For my part, i made this : expandcollapse popup#Include <date.au3> #include <file.au3> #Include <GUIconstants.au3> #include "image_get_info.au3" $replog = IniRead("sizesorter.ini", "replog", "key", "NotFound") $adminlog = IniRead("sizesorter.ini", "adminlog", "key", "NotFound") $folderdft = IniRead("sizesorter.ini", "Repertoire", "key", "NotFound") $finalfolder = FileSelectFolder("Choisir un dossier", "", 2, $folderdft) $sizeref = IniRead("sizesorter.ini", "sizeref", "key", "NotFound") $repsizeless = "sizelessthan" & $sizeref & "\" $repsizeup = "sizemorethan" & $sizeref & "\" $multiplic = $sizeref*$sizeref $target = $finalfolder & "\" $nb = IniRead("sizesorter.ini", "NbExtense", "key", "NotFound") $deep = IniRead("sizesorter.ini", "DupliDeep", "key", "NotFound") $sNewDate = _DateAdd( 'n',-1, _NowCalc()) TrayTip("'SizeSorter'", "Lancement à " & _NowTime(), 20, 1) $log = FileOpen($replog & $adminlog, 1) FileWrite($log, "==============================================================================" & @CRLF) FileWrite($log, "Lancement de SizeSorter - " & _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF) FileWrite($log, "------------------------------------------------------------------------------" & @CRLF) FileWrite($log, "Cible : " & $target & @CRLF) FileWrite($log, "------------------------------------------------------------------------------" & @CRLF) FileWrite($log, "Nom initial -->> Calcul" & @CRLF) FileWrite($log, "------------------------------------------------------------------------------" & @CRLF) FileClose($log) For $i=1 to $nb $look = IniRead("sizesorter.ini", "ext" & $i, "Key", "NotFound") $assembl = "*." & $look $search = FileFindFirstFile($target & $assembl) If $search = -1 Then $log = FileOpen($replog & $adminlog, 1) FileWrite($log, @CRLF & "------------------------------------------------------------------------------" & @CRLF & @CRLF) FileWrite($log, "Aucun fichier '" & $look & "' trouvé." & @CRLF) FileWrite($log, "------------------------------------------------------------------------------" & @CRLF) FileClose($log) Else $log = FileOpen($replog & $adminlog, 1) While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If Not @error Then $aInfo = _ImageGetInfo($target & $file) $Width = _ImageGetParam($aInfo, "Width") $Height = _ImageGetParam($aInfo, "Height") $calcul = $Width*$Height If $calcul < $multiplic Then FileWrite($log, "------------------------------------------------------------------------------" & @CRLF) FileWrite($log, " Fichiers " & $look & " trouvés : " & @CRLF & @CRLF) FileWrite($log, "------------------------------------------------------------------------------" & @CRLF) ;FileWrite($log, $file & " -->> " & $Width & " x " & $Height & " = " & $calcul & @CRLF) FileWrite($log, $file & " -->> petite taille -> déplacer" & @CRLF) If FileExists($target & $repsizeless & $file) Then FileWrite($log, " " & $file & " -->> Existe déjà dans le répertoire cible !!!" & @CRLF & @CRLF) Else FileMove($target & $file, $target & $repsizeless & $file, 8) EndIf Else ;FileWrite($log, $file & " -->> pas petite taille." & @CRLF) ;FileMove($target & $file, $target & $repsizeup & $file, 8) EndIf EndIf WEnd FileClose($search) FileClose($log) EndIf Next $log = FileOpen($replog & $adminlog, 1) FileWrite($log, "==============================================================================" & @CRLF) FileWrite($log, "Fin du traitement - " & _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF & @CRLF & @CRLF) FileClose($log) MsgBox(4096, "Fin du traitement SizeSorter", "Tous les fichiers ont été triés et copiés selon leur taille" & @CRLF) TrayTip("clears any tray tip","",0) It works well. Need this ini file. Your size reference is sizeref=500, like 500x500 pixels. [replog] Key=C:\admintools\exifsorter\ [adminlog] Key=sorterlog.txt [Repertoire] Key=C:\rep_oltr\perso\images\flickr\Trieur [multiplication] Key=250000 [sizeref] Key=500 [DupliDeep] Key=20 [NbExtense] Key=6 [ext1] Key=jpg [ext2] Key=gif [ext3] Key=bmp [ext4] Key=tif [ext5] Key=jpe [ext6] Key=jpeg Link to comment Share on other sites More sharing options...
Kip Posted March 21, 2008 Share Posted March 21, 2008 $Image = _GDIPlus_ImageLoadFromFile("File.bmp") $Width = _GDIPlus_ImageGetWidth($Image) $Height = _GDIPlus_ImageGetHeight($Image) MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now