Seitenanzahl einer Tif-Datei ermitteln

  • Servus,

    wie der Titel ja schon sagt, suche in nach einer Funktion/Möglichkeit die Seitenanzahl von Mehrseitigen TIF-Dateien zu ermitteln.
    Leider ist meine Suche bisher nur ins leere oder zu kostenpflichtigen 3. Programmen geführt, auf die ich lieber verzichen will.

    Falls von euch jemand einen Weg kennt, wäre es sehr lieb von euch mir diesen mitzuteilen :)

    mfg
    Sven

    Einmal editiert, zuletzt von sev0n (26. November 2008 um 08:33)

  • Hallo anno2008

    danke für deine antwort.

    Wenns in AutoIt funktioniert wäre das wunderbar, aber wenn nicht (also ein Programmschnitzel aus irgendeiner Sprache) wäre das auch kein großes Problem

    Ich bräuchte es halt autonom, also so, das ich es programmgesteuert ansteuern kann und am besten so das der Benutzer nichts davon merkt.

    Das von dir gepostete Programm zählt zwar schön die Seiten, aber ist für meine Zwecke leider nicht geeinget.

  • Hi

    Steht bei den Eigenschaften die richtige Seitenanzahl? (Rechte Maustaste -> Eigenschaften -> DateiInfo)
    Dann kannst du das vielleicht mit der ExtProp.au3 UDF auslesen:

    Spoiler anzeigen
    [autoit]

    ;===============================================================================
    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]

    Habs nicht getestet, da ich keine mehrseitige Tif hab (und auch nicht weiß, wie man sowas erstellt ;))

    lgE

  • Hi,
    wenn man mit den richtigen Begriffen sucht findet man auch.

    google

    ich könnte ja theoretisch ein Programms schreiben, aber ich hab auch kein mehrseitiges Tiff. Kannst du mal ein solches ding hochladen?

    2 Mal editiert, zuletzt von anno2008 (25. November 2008 um 16:44)

  • Also so geht es:

    [autoit]

    MsgBox(0,"Seitenanzahl",_GetExtProperty(@ScriptDir & "\multipage.tif",13))

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ;===============================================================================
    ; Function Name: GetExtProperty($sPath,$iProp)
    ; Description: Returns an extended property of a given file.
    ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from.
    ; $iProp - The numerical value for the property you want returned. If $iProp is is set
    ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
    ; The properties are as follows:
    ; Name = 0
    ; Size = 1
    ; Type = 2
    ; DateModified = 3
    ; DateCreated = 4
    ; DateAccessed = 5
    ; Attributes = 6
    ; Status = 7
    ; Owner = 8
    ; Author = 9
    ; Title = 10
    ; Subject = 11
    ; Category = 12
    ; Pages = 13
    ; Comments = 14
    ; Copyright = 15
    ; Artist = 16
    ; AlbumTitle = 17
    ; Year = 18
    ; TrackNumber = 19
    ; Genre = 20
    ; Duration = 21
    ; BitRate = 22
    ; Protected = 23
    ; CameraModel = 24
    ; DatePictureTaken = 25
    ; Dimensions = 26
    ; Width = 27
    ; Height = 28
    ; Company = 30
    ; Description = 31
    ; FileVersion = 32
    ; ProductName = 33
    ; ProductVersion = 34
    ; Requirement(s): File specified in $spath must exist.
    ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties
    ; On Failure - 0, @Error - 1 (If file does not exist)
    ; Author(s): Simucal ([email='Simucal@gmail.com'][/email])
    ; Note(s):
    ;
    ;===============================================================================
    Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
    SetError(1)
    Return 0
    Else
    $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
    $oShellApp = ObjCreate ("shell.application")
    $oDir = $oShellApp.NameSpace ($sDir)
    $oFile = $oDir.Parsename ($sFile)
    If $iProp = -1 Then
    Local $aProperty[35]
    For $i = 0 To 34
    $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
    Next
    Return $aProperty
    Else
    $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
    If $sProperty = "" Then
    Return 0
    Else
    Return $sProperty
    EndIf
    EndIf
    EndIf
    EndFunc ;==>_GetExtProperty

    [/autoit]

    lgE

    • Offizieller Beitrag

    :) - Da hat ja einer die gleiche Idee gehabt, wie ich.

    Spoiler anzeigen
    [autoit]

    #include<array.au3>
    $filename = @ScriptDir & "\multipage.tif"
    $ret = _FileInfoExtended($filename)
    ;~ _ArrayDisplay($ret)
    MsgBox(0, 'Anzahl Seiten', $ret[1][13])
    ;===============================================================================
    ; Function Name: _FileInfoExtended($FolderOrFile)
    ; Description:: Gibt erweiterte Dateiinformationen einer Datei oder aller Dateien
    ; eines Ordners zurück. Automatische Erkennung Datei oder Ordner.
    ; Parameter(s): $FolderOrFile Pfad der Datei/des Ordners
    ; Return Value(s): Array mit 34 Spalten, 1 Zeile je Datei
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;===============================================================================
    Func _FileInfoExtended($FolderOrFile)
    If Not FileExists($FolderOrFile) Then Return SetError(1)
    Local $objShell = ObjCreate("Shell.Application")
    Local $arrHeaders[34], $Type = 'F'
    If StringInStr(FileGetAttrib($FolderOrFile), 'D') Then
    Local $objFolder = $objShell.Namespace($FolderOrFile)
    $Type = 'D'
    Else
    Local $objFSO = ObjCreate("Scripting.FileSystemObject")
    Local $objFile = $objFSO.GetFile($FolderOrFile)
    Local $FileName = $objFSO.GetFileName($objFile)
    Local $objFolder = $objShell.Namespace($objFSO.GetParentFolderName($objFile))
    EndIf
    Local $arRet[1][34]
    For $i = 0 To 33
    $arrHeaders[$i] = $objFolder.GetDetailsOf($objFolder.Items, $i)
    $arRet[0][$i] = $arrHeaders[$i]
    Next
    For $strFileName In $objFolder.Items
    If $Type = 'F' And $objFolder.GetDetailsOf($strFileName, 0) <> $FileName Then ContinueLoop
    ReDim $arRet[UBound($arRet)+1][34]
    For $i = 0 to 33
    $arRet[UBound($arRet)-1][$i] = $objFolder.GetDetailsOf($strFileName, $i)
    Next
    Next
    Return $arRet
    EndFunc ;_FileInfoExtended

    [/autoit]

    Edit: Übrigens, die DLL ist kostenfrei limitiert auf die Erkennung von max. 10 Seiten.

  • jawoll :)

    es funktioniert ohne probleme

    vielen dank an euch alle :)

    echt super forum mit schneller kompetenter lösung :D
    einfach nur TOP :rock: