Jump to content

UDF: ImageGetInfo


Lazycat
 Share

Recommended Posts

This looks like a great script which for some reason does not run on my system (Windows XP SP2).

I have downloaded AutoIT Beta v 3.2.5.0 and when running the Syntax Check Beta I get the following console message:

C:\PLMapper\image_get_info.au3(76,21) : ERROR: DllStructDelete(): undefined function.

DllStructDelete($p)

If I go to Beta Help - DllStructDelete is not a listed Fuction Reference

Edit

And this reference to the latest version of the scripts zip file fails

http://www.autoitscript.com/forum/index.ph...13096&st=15

Ant..

Edited by anixon
Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Any plans on adding Write functionality?

Hm, what you want to write here? :)

Anyway, no plans for writing.

This looks like a great script which for some reason does not run on my system (Windows XP SP2).

Assume you downloaded version from first post. There was very old one. Now I'm updated it, so you can download it again.
Link to comment
Share on other sites

  • 1 month later...

Dear LazyCat et al.,

First of all, let me say that, at a glance, I am very intrigued and impresed both by Autoit and ImageGetInfo. I am entirely new to AUTOIT (and pretty new to programming in general - some vbscript, javascript and vba experience) and stumbled upon this site while looking for a way to read metadata from tiff files.

Can you clarify the following for me and maybe give me some advice. Can ImageGetInfo identify and output any tiff tag based on the tag number?

I am using an MS Access database to record information about images files on my PC. I can use FileSystemObject to get basic info and save it to my table, but ideally I want to tell Access to access more specific tiff tag information and save that too.

Is this at all possible either by using your ImageGetInfo or by any other means you are aware of?

Many thanks for you help.

forumsUID

Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

I made this program to be used with your. If it can help someone...

Use : Select a folder, find jpeg files, take the date with year and month, create a folder if not exist, and move files to it, according to their date file property.

So simple, so easy to use, and so helpful to sort your pics from your cam :)

#Include <date.au3>

#include <file.au3>

#Include <GUIconstants.au3>

#include "image_get_info.au3"

$replog = IniRead("mediasfinder.ini", "replog", "key", "NotFound")

$adminlog = IniRead("mediasfinder.ini", "adminlog", "key", "NotFound")

$defaultfolder = IniRead("mediasfinder.ini", "Repertoire", "key", "NotFound")

$target = FileSelectFolder("Sélection du dossier", "C:\", 2, $defaultfolder)

$nb = IniRead("mediasfinder.ini", "NbLogs", "key", "NotFound")

$sNewDate = _DateAdd( 'n',-1, _NowCalc())

$look = IniRead("mediasfinder.ini", "extension", "Key", "NotFound")

$log = FileOpen($replog & $adminlog, 2)

FileWrite($log, "Lancement : ")

FileWrite($log, _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF)

FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)

FileWrite($log, "Fichiers " & $look & " trouvés : " & @CRLF)

;english : FileWrite($log, "Files " & $look & "found : " & @CRLF)

FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)

FileWrite($log, "Nom initial --->>> Date EXIF ou de fichier -> Destination" & @CRLF)

;english : FileWrite($log, "Initial Name --->>> EXIF's Date or file's date -> Destination" & @CRLF)

FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)

FileClose($log)

For $i=1 to $nb

$search = FileFindFirstFile($target & $look)

If $search = -1 Then

$log = FileOpen($replog & $adminlog, 1)

FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)

FileWrite($log, "Le programme n'a pas trouvé de fichiers " & $look & @CRLF)

;english : FileWrite($log, "Program didn't find files " & $look & @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)

$datefichier = _ImageGetParam($aInfo, "DateTimeOriginal")

$remplace = StringReplace($datefichier, ":", "")

$final = StringReplace($remplace, " ", "")

$t = FileGetTime($target & $file, 1)

$anneemois = $t[0] & $t[1]

EndIf

If $final > 0 Then

FileWrite($log, " " & $file & " --->>> " & $final & ".jpg" & " -> " & $anneemois & @CRLF)

If FileExists($target & $anneemois) Then

FileMove($target & $file, $target & $anneemois & "\" & $final & ".jpg", 8)

Else

FileWrite($log, @CRLF & "Création du répertoire : " & $anneemois & @CRLF & @CRLF)

;english : FileWrite($log, @CRLF & "Directory creation : " & $anneemois & @CRLF & @CRLF)

FileMove($target & $file, $target & $anneemois & "\" & $final & ".jpg", 8)

EndIf

; $t = FileGetTime($target & $file, 1, 1)

Else

$totale = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & $t[5]

FileWrite($log, " " & $file & " --->>> " & $totale & ".jpg" & " -> " & $anneemois & @CRLF)

If FileExists($target & $anneemois) Then

FileMove($target & $file, $target & $anneemois & "\" & $totale & ".jpg", 8)

Else

FileWrite($log, @CRLF & "Création du répertoire : " & $anneemois & @CRLF & @CRLF)

;english : FileWrite($log, @CRLF & "Directory creation : " & $anneemois & @CRLF & @CRLF)

FileMove($target & $file, $target & $anneemois & "\" & $totale & ".jpg", 8)

EndIf

EndIf

WEnd

FileClose($search)

FileClose($log)

EndIf

$log = FileOpen($replog & $adminlog, 1)

FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)

FileWrite($log, "Fin du traitement" & @CRLF & @CRLF & @CRLF)

;english : FileWrite($log, "End of work" & @CRLF & @CRLF & @CRLF)

Next

MsgBox(4096, "Fin du traitement", "Tous fichiers trouvés déplacés" & @CRLF & @CRLF & "Et si aucun fichier, eh bien rien !")

;english : MsgBox(4096, "End of work", "All files moved" & @CRLF & @CRLF & "And if no file, so nothing !")

Link to comment
Share on other sites

Update of this script. Include the FileSelectFolder.

:)

#Include <date.au3>
#include <file.au3>
#Include <GUIconstants.au3>
#include "image_get_info.au3"
$replog = IniRead("mediasfinder.ini", "replog", "key", "NotFound")
$adminlog = IniRead("mediasfinder.ini", "adminlog", "key", "NotFound")
$defaultfolder = IniRead("mediasfinder.ini", "Repertoire", "key", "NotFound")
$select = FileSelectFolder("Sélection du dossier", "C:\", $defaultfolder)
$target = $select & "\"
$nb = IniRead("mediasfinder.ini", "NbLogs", "key", "NotFound")
$sNewDate = _DateAdd( 'n',-1, _NowCalc())
$look = IniRead("mediasfinder.ini", "extension", "Key", "NotFound")
$log = FileOpen($replog & $adminlog, 2)
FileWrite($log, "Lancement : ")
FileWrite($log, _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF)
FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)
FileWrite($log, "Fichiers " & $look & " trouvés : " & @CRLF)
FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)
FileWrite($log, "Nom initial --->>> Date EXIF ou de fichier -> Destination" & @CRLF)
FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)
FileClose($log)
For $i=1 to $nb
    $search = FileFindFirstFile($target & $look)
    If $search = -1 Then
        $log = FileOpen($replog & $adminlog, 1)
        FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)
        FileWrite($log, "Le programme n'a pas trouvé de fichiers dans " & $target & @CRLF)
        FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)
        FileClose($log)
        MsgBox(4096, "Aucun fichier", "Aucun fichier trouvé dans " & $target & @CRLF)
    Else
        $log = FileOpen($replog & $adminlog, 1)
        While 1
            $file = FileFindNextFile($search)
            If @error Then ExitLoop
            If Not @error Then
            $aInfo = _ImageGetInfo($target & $file)
            $datefichier = _ImageGetParam($aInfo, "DateTimeOriginal")
            $remplace = StringReplace($datefichier, ":", "")
            $final = StringReplace($remplace, " ", "")
            $t = FileGetTime($target & $file, 1)
            $anneemois = $t[0] & $t[1]
            EndIf
            If $final > 0 Then 
                FileWrite($log, " " & $file & " --->>> " & $final & ".jpg" & " -> " & $anneemois & @CRLF)
                If FileExists($target & $anneemois) Then 
                    FileMove($target & $file, $target & $anneemois & "\" & $final & ".jpg", 8)
                Else
                    FileWrite($log, @CRLF & "Création du répertoire : " & $anneemois & @CRLF & @CRLF)
                    FileMove($target & $file, $target & $anneemois & "\" & $final & ".jpg", 8)
                EndIf
            Else
                $totale = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & $t[5]
                FileWrite($log, " " & $file & " --->>> " & $totale & ".jpg" & " -> " & $anneemois & @CRLF)
                If FileExists($target & $anneemois) Then 
                    FileMove($target & $file, $target & $anneemois & "\" & $totale & ".jpg", 8)
                Else 
                    FileWrite($log, @CRLF & "Création du répertoire : " & $anneemois & @CRLF & @CRLF)
                    FileMove($target & $file, $target & $anneemois & "\" & $totale & ".jpg", 8)
                EndIf
            EndIf
        WEnd
        FileClose($search)
        FileClose($log)
    EndIf
    $log = FileOpen($replog & $adminlog, 1)
    FileWrite($log, "------------------------------------------------------------------------------" & @CRLF)
    FileWrite($log, "Fin du traitement" & @CRLF & @CRLF & @CRLF)
Next
MsgBox(4096, "Fin du traitement", "Tous fichiers trouvés déplacés" & @CRLF & @CRLF & "Et si aucun fichier n'avait été trouvé..." & @CRLF & "eh bien keepcool  : rien !")
Link to comment
Share on other sites

  • 1 year later...

Hi, i get the wrong resolution with jpeg images

Real values:

Width - 3872

Height - 2592

UDF Values:

Width - 8195

Height - 8207

Everything else seems to work perfectly.

Thanks for a great UDF

I run Windows XP SP3

Autoit BETA v3.2.12.1

the udf

Version: 2.4

Date: 22.05.2007

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 1 year later...

I have this script

#include <image_get_info.au3>
#include <Array.au3>

$pfad = "E:\Bild.jpg"

$aInfo = _ImageGetInfo($pfad)
ConsoleWrite($aInfo & @CRLF)

With AutoIt 3.3.0.0 I got this result

Make=Canon

Model=Canon DIGITAL IXUS 500

Orientation=Normal

XResolution=180

YResolution=180

ResolutionUnit=Inch

DateTime=2010:03:10 16:15:16

ExposureTime=0.0166666666666667

FNumber=2.8

ExifVersion=

DateTimeOriginal=2010:03:10 16:15:16

DateTimeDigitized=2010:03:10 16:15:16

ComponentsConfiguration=YCbCr

CompressedBitsPerPixel=3

ShutterSpeedValue=5.90625

ApertureValue=2.96875

ExposureBiasValue=0

MaxApertureValue=2.96875

MeteringMode=MultiSegment

Flash=Fired, Auto

FocalLength=7.40625

UserComments=

SensingMethod=OneChipColorArea

ExposureMode=Auto

WhiteBalance=Auto

DigitalZoomRatio=1

SceneCaptureType=Standard

Width=2592

Height=1944

With AutoIt 3.3.4.0 I got this result

Width=2592

Height=1944

Can you please look whats going wrong?

Thanks

Edited by Tweaky
Link to comment
Share on other sites

  • 3 weeks later...

@LazyCat

Thanks a lot for the very useful image_get_info.au3

Probably after doing some changes, you did not define several variables. As I always use Opt("MustDefineVars",1) I had some problems.

I added:

In Func ParseExif($hFile, $exif_offset): Local $nTiffHdrOffset,$pHdr,$nIFDOffset,$pCnt,$nIFDCount,$pTag,$nCnt,$id,$nEIFDCount

In Func _AddSpecial(ByRef $sInfo, $ID, $nValue): Local $nModeState

In Func _IntR($nInt, $nOrder = 1): Local $curbyte

and it works, as far as I tested, I tested only with JPGs.

Do you know any UDF for adding/editing EXIF-Comments? I need this for a script I'm writing.

Edited by wolfbartels
Link to comment
Share on other sites

  • 4 weeks later...

Hi Coding Cat, (not lazy anymore :idea: )

On JPG-files of some cameras there are both EXIF-Parameters "UserComments" and "Comment", causing the UDF _ImageGetParam() to become confused, because it searches only for Comment.

An easy solution is to include the inicial @LF and final "=" at $aParam when searching in $aData.

;===============================================================================
; Get param by name from function result
;===============================================================================
Func _ImageGetParam($sData, $sParam)
    Local $nParamPos = StringInStr(@LF & $sData,@LF & $sParam & "=") ; @LF and "=" added
    If $nParamPos Then
        $sData = StringTrimLeft($sData, $nParamPos + StringLen($sParam))
        Return StringLeft($sData, StringInStr($sData, @LF) - 1)
    Endif
    Return ""
EndFunc

Now the Func will always give a correct Return.

The attached photo is an example for testing this.

post-10427-12724730653462_thumb.jpg

Link to comment
Share on other sites

wolfbartels

Thanks, updated function and added initializations of locals. New version uploaded.

I found another 2 Locals that need to be initialized in Func _ImageGetInfoJPG($hFile, $nFileSize) in new image_get_info.au3 ver 2.7 line 145:

Local $t, $nUnit

I only tested with JPGs, it works fine now.

Link to comment
Share on other sites

  • 3 weeks later...

Great UDF, thanks a lot for this one :idea:.

Attached PNG sends _ImageGetInfoPNG() into an endless loop.

I solved it by replacing this:

Func _ImageGetInfoPNG($hFile)
    Local $sInfo = "", $nNextOffset = 8, $nBlockSize, $nID
    Local $nBPP, $nCol, $sAlpha, $nXRes, $nYRes, $sKeyword, $nKWLen
    Local $pBlockID = DllStructCreate("ulong;ulong")
    While $nID <> 0x49444154; IDAT (picture data)
        $pBlockID = _FileReadToStruct($pBlockID, $hFile, $nNextOffset)
        $nBlockSize = _IntR(DllStructGetData($pBlockID, 1))
        $nID = _IntR(DllStructGetData($pBlockID, 2))

with this:

Func _ImageGetInfoPNG($hFile)
    Local $sInfo = "", $nNextOffset = 8, $nBlockSize, $nID
    Local $nBPP, $nCol, $sAlpha, $nXRes, $nYRes, $sKeyword, $nKWLen
    Local $pBlockID = DllStructCreate("ulong;ulong")
    Local $nID_Save = -1
    While $nID <> 0x49444154 AND $nID <> $nID_Save; IDAT (picture data)
        $nID_Save = $nID
        $pBlockID = _FileReadToStruct($pBlockID, $hFile, $nNextOffset)
        $nBlockSize = _IntR(DllStructGetData($pBlockID, 1))
        $nID = _IntR(DllStructGetData($pBlockID, 2))
Link to comment
Share on other sites

KaFu

This is ok as temporary solution, but not fully correct, since some blocks can appear more then once. While script not support this situation anyway, in this case you can miss later blocks. Seems here the bug in the parser somewere - the block sizes are become mad and loop going infinite. Maybe due changes in newer Autoit versions.

Link to comment
Share on other sites

...since some blocks can appear more then once.

What's you best guess of how often a block can max appear in a row? 3 times? Then something likes this would be better as a workaround (I think i remember the false $nID returned by above sample picture did not match a case, thus no extra info would be added):

Func _ImageGetInfoPNG($hFile)
    Local $sInfo = "", $nNextOffset = 8, $nBlockSize, $nID
    Local $nBPP, $nCol, $sAlpha, $nXRes, $nYRes, $sKeyword, $nKWLen
    Local $pBlockID = DllStructCreate("ulong;ulong")
    Local $nID_Save = -1, $nID_Save_Counter = 0
    While $nID <> 0x49444154 AND $nID_Save_Counter < 4 ; IDAT (picture data)
        $pBlockID = _FileReadToStruct($pBlockID, $hFile, $nNextOffset)
        $nBlockSize = _IntR(DllStructGetData($pBlockID, 1))
        $nID = _IntR(DllStructGetData($pBlockID, 2))
        if $nID = $nID_Save Then
            $nID_Save_Counter +=1
        Else
            $nID_Save_Counter = 0
        endif
        $nID_Save = $nID
Edited by KaFu
Link to comment
Share on other sites

  • 2 months later...

Once again, thanks for sharing!

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...