Where are images metadata and album data stored on iPhone? and how to extract them? I am trying to connect to my iPhone via iTunesMobileDevice.dll and other libraries provided by iTunes. So far I am able to reach the file system and copy images from iPhone. However images are stored in directories titled 101APPLE to 109APPLE and the filesystem looks something like this:

...
/PhotoStreamsData/.MISC
/PhotoStreamsData/.MISC/Incoming
/DCIM
/DCIM/101APPLE
...
/DCIM/.MISC
/DCIM/.MISC/Timelapse
/DCIM/.MISC/Incoming
...
/PhotoData/Metadata
/PhotoData/Metadata/DCIM
/PhotoData/Metadata/DCIM/109APPLE
/PhotoData/Metadata/DCIM/108APPLE
/PhotoData/Metadata/DCIM/107APPLE
/PhotoData/Metadata/DCIM/106APPLE
/PhotoData/AlbumsMetadata
...


Now I need to extract the Album data as well and rearrange my images in the related albums which I have made on my iPhone.

My question is that where the album data (and other metadata about images like time or ...) is stored? and how is it possible to extract them?

Extra Information to Clarify My Question:

I need information about iOS File System. Specifically about how and where iOS keeps data about photo albums, i.e. which photos belong to which albums? the date that photos are taken, etc. Finally I need to be able to rearrange the folders which are like above into what we see on the iPhone Gallery. something like this:

Photo Gallery:
- Album1:
    -IMG_001.JPG
    -IMG_002.JPG
    -IMG_003.JPG
- Album2:
    -IMG_002.JPG
    -IMG_004.JPG
    -IMG_005.JPG
In this article, I'll answer the question on how to examine photo metadata with the exiftool.

There is the apple supplied sips command. man sips

$ sips -g format  /Users/mac/Desktop/rockSlab.JPG  
/Users/mac/Desktop/rockSlab.jpg
  format: jpeg


I give an example of exiftool for use on a mac. The use of exiftool on Windows  command line will be the same.    I have heard a lot about exiftool.  I wrote an applescript to use this tool.  You could use any language you like.

I assume you were connecting your iPhone to a mac, but the some concepts should apply.  Applescript is supposed to be readable to about anyone.  It's in "English".

fyi:  

(* *) 
  is a comment
-- 
  is a one line comment
set a to b 
  is a = b in normal languages
log
  is a print statement
display dialog
  put up a dialog box
common(dropped_items)
  means call function common with argument dropped_items
on common(input)
  is the function header


applescript app:

    (* 
  This script provides an example of using the command line ExifTool tool. 
  The script was written to answer ASC Discussion question https://discussions.apple.com/thread/8511361

   Shows exif data before and after any change.  You may run the script by either double clicking on the app or droping files on the app. I Included debugging statements on run path.

   Requires ExifTool by Phil Harvey.  Download
       https://www.sno.phy.queensu.ca/~phil/exiftool/

    You need to place exiftool in your default path.  I suggest "/usr/local/bin/exiftool". No you cannot go into terminal and alter your path.  
    You can alter this script to change the path.   

  Input: 
      Drop files on AppleScript icon.
      or
      double click on the app.
      or 
      run from the script editor to see the log output. You will fist need to click on the "list" icon at the bottom of the script editor screen.

  Output:  
      Creates file "tryAttachmentsLog.txt" in you home folder. 
      When run from the script editor, you get logged output.


  How to save: 
        Save as an Application Bundle.  Don't check the two boxes below.


For testing, run in the Script Editor.
    1) Click on the Event Log tab to see the output from the log statement
    2) Click on Run


Author: rccharles

 *)


-- Gets invoked here when you run in AppleScript editor.
-- This is for testing although you could use it for production
on run
    -- Write a message into the event log.
    log "  --- Starting on " &amp; ((current date) as string) &amp; " --- "

    set desktopPath to (path to desktop) as string
    log "desktopPath = " &amp; desktopPath


    try
        set see to choose file
    on error errMsg number n
        -- Be sure to select a file on your DESKTOP.
        set see to alias (desktopPath &amp; "rockSlab.jpg")
    end try

    -- Simulate dropped items list.
    set dropped_items to {see}

    common(dropped_items)

end run



-- Gets invoked here when something is dropped on this AppleScript icon
on open dropped_items
    display dialog "Number of items dropped is " &amp; (count of dropped_items) &amp; ". " giving up after 3

    common(dropped_items)

    --display dialog "Processed " &amp; (count of dropped_items) &amp; ". " giving up after 3

end open



on common(dropped_items)
    -- Required by debug routine.   
    global debugRunning
    set debugRunning to ""

    -- Write a message into the event log.
    log "  --- Starting on " &amp; ((current date) as string) &amp; " --- "
    tell application "Script Editor"
        activate
    end tell


    log "class = " &amp; class of dropped_items

    try
        set pathToExiftool to do shell script "which /usr/local/bin/exiftool "
        log "Found exiftool here: " &amp; return &amp; pathToExiftool
    on error errMsg number n
        set theMsg to "could not find exiftool. Error message was " &amp; errMsg &amp; " error number was  " &amp; n
        log theMsg
        display dialog theMsg giving up after 20
        return 1
    end try


    repeat with droppedItem in dropped_items
        log "class droppedItem = " &amp; class of droppedItem
        set unixDroppedItem to POSIX path of droppedItem
        log "unixDroppedItem = " &amp; unixDroppedItem
        set quotedUnixDroppedItem to quoted form of unixDroppedItem
        log "quoted form is " &amp; quotedUnixDroppedItem
        set toUnix to pathToExiftool &amp; " " &amp; quotedUnixDroppedItem
        set seeUnix to do shell script toUnix
        debugLog("--- Before ---- " &amp; unixDroppedItem &amp; " ---------------")
        debugLog(seeUnix)

        --  Perfrom whatever action you want out of exiftool
        (* 
        see tags in a picture: 
        exiftool   /Users/mac/Desktop/rockSlab.JPG 
        the tags will have spaces in them leave out the spaces when typing the tag name 
        *)
        set toUnix to pathToExiftool &amp; " " &amp; "-CreateDate -CircleOfConfusion   " &amp; quotedUnixDroppedItem

        set seeUnix to do shell script toUnix
        log return &amp; "result of exiftool is  " &amp; return &amp; return &amp; seeUnix &amp; return &amp; return
        debugLog(return &amp; "result of exiftool is  " &amp; seeUnix &amp; return)
        set toUnix to pathToExiftool &amp; " " &amp; quotedUnixDroppedItem
        set seeUnix to do shell script toUnix
        debugLog("---&gt;&gt;&gt; After &lt;&lt;&lt; " &amp; unixDroppedItem &amp; " -------------------")
        debugLog(seeUnix)
    end repeat


end common



(* ======================== Common Subroutines ======================= *)
-- ------------------------------------------------------  
(*
*)
on appendToFile(fileId, theData)

    local theSize, writeWhere

    set theSize to (get eof fileId)
    set writeWhere to theSize + 1 as integer
    write theData to fileId starting at writeWhere

end appendToFile

-- ------------------------------------------------------  
(* 
 debug(&lt;string&gt;)
 Write messages to a log file.

  -- Need to place these two lines in the calling routine. 
    global debugRunning
    set debugRunning to ""
 -- references appendToFile()   
  -- example:
    debug("start program. Reading from " &amp; listOfFiles)

   found here: /Users/mac/Documents/BJ\ Prior\ Years/BJ2004/sendmailapp2\ copy 

*)
on debug(theMessage)
    -- return
    global debugRunning
    local theSize, startupDiskName, pathToLog, fileReference

    set pathToLog to (path to home folder as text) &amp; "tryAttachmentsLog.txt"
    -- log "pathToLog is " &amp; pathToLog
    -- display dialog "pathToLog is " &amp; pathToLog giving up after 4

    try
        -- Complete the path.
        set pathToLog to pathToLog as text
        set fileReference to (open for access file pathToLog ¬
            with write permission)

        if debugRunning = "" then
            set theSize to (get eof fileReference)
            if theSize &gt; 0 then
                appendToFile(fileReference, " " &amp; return)
            end if
            appendToFile(fileReference, "   --- debug on " &amp; ((current date) as string) &amp; "   --- " &amp; return)
            set debugRunning to "running"
        end if
        -- log "theMessage " &amp; theMessage
        -- display dialog "in debug..." &amp; return &amp; "theMessage " &amp; theMessage giving up after 3
        appendToFile(fileReference, theMessage &amp; return)

        close access fileReference
        tell application "Finder"
            set the creator type of the file pathToLog ¬
                to "R*ch"
        end tell
    on error mes number n
        try
            set commonErr to "error ... " &amp; mes &amp; " error number is " &amp; n
            log commonErr
            close access fileReference
            display dialog commonErr giving up after 4
        end try

    end try
    -- log "end of debug"
end debug

(*
write log message to script editor log and to our file log 
*)
on debugLog(theMessage)
    log "debugLog: " &amp; theMessage
    return debug(theMessage)
end debugLog


Example output:

(*  --- Starting on Wednesday, June 12, 2019 at 5:45:54 PM --- *)
(*desktopPath = Macintosh SSD:Users:mac:Desktop:*)
(*  --- Starting on Wednesday, June 12, 2019 at 5:45:59 PM --- *)
(*class = list*)
(*Found exiftool here: 
/usr/local/bin/exiftool*)
(*class droppedItem = alias*)
(*unixDroppedItem = /Users/mac/Desktop/rockSlab.jpg*)
(*quoted form is '/Users/mac/Desktop/rockSlab.jpg'*)
(*debugLog: --- Before ---- /Users/mac/Desktop/rockSlab.jpg ---------------*)
(*debugLog: ExifTool Version Number         : 10.36
File Name                       : rockSlab.jpg
Directory                       : /Users/mac/Desktop
File Size                       : 5.9 MB
File Modification Date/Time     : 2019:06:12 17:20:33-04:00
File Access Date/Time           : 2019:06:12 17:45:54-04:00
File Inode Change Date/Time     : 2019:06:12 17:21:08-04:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 4
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : Photos 1.0.1
Modify Date                     : 2019:06:12 17:04:56
Exposure Time                   : 1/120
F Number                        : 2.8
Exposure Program                : Program AE
ISO                             : 100
Exif Version                    : 0221
Date/Time Original              : 2019:06:12 17:04:56
Create Date                     : 2019:06:12 17:04:56
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/120
Aperture Value                  : 2.8
Brightness Value                : 5.52228164
Metering Mode                   : Multi-segment
Flash                           : Auto, Did not fire
Focal Length                    : 3.9 mm
Subject Area                    : 1295 967 699 696
Run Time Flags                  : Valid
Run Time Value                  : 3126374362166
Run Time Epoch                  : 0
Run Time Scale                  : 1000000000
Sub Sec Time Original           : 493
Sub Sec Time Digitized          : 493
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 1936
Exif Image Height               : 2592
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 35 mm
Scene Capture Type              : Standard
Lens Info                       : 3.85mm f/2.8
Lens Make                       : Apple
Lens Model                      : iPhone 4 back camera 3.85mm f/2.8
XMP Toolkit                     : XMP Core 5.4.0
Creator Tool                    : Photos 1.0.1
Date Created                    : 2019:06:12 17:04:56
Current IPTC Digest             : d41d8cd98f00b204e9800998ecf8427e
IPTC Digest                     : d41d8cd98f00b204e9800998ecf8427e
Profile CMM Type                : Lino
Profile Version                 : 2.1.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 1998:02:09 06:49:00
Profile File Signature          : acsp
Primary Platform                : Microsoft Corporation
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : IEC
Device Model                    : sRGB
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : HP
Profile ID                      : 0
Profile Copyright               : Copyright (c) 1998 Hewlett-Packard Company
Profile Description             : sRGB IEC61966-2.1
Media White Point               : 0.95045 1 1.08905
Media Black Point               : 0 0 0
Red Matrix Column               : 0.43607 0.22249 0.01392
Green Matrix Column             : 0.38515 0.71687 0.09708
Blue Matrix Column              : 0.14307 0.06061 0.7141
Device Mfg Desc                 : IEC http://www.iec.ch
Device Model Desc               : IEC 61966-2.1 Default RGB colour space - sRGB
Viewing Cond Desc               : Reference Viewing Condition in IEC61966-2.1
Viewing Cond Illuminant         : 19.6445 20.3718 16.8089
Viewing Cond Surround           : 3.92889 4.07439 3.36179
Viewing Cond Illuminant Type    : D50
Luminance                       : 76.03647 80 87.12462
Measurement Observer            : CIE 1931
Measurement Backing             : 0 0 0
Measurement Geometry            : Unknown
Measurement Flare               : 0.999%
Measurement Illuminant          : D65
Technology                      : Cathode Ray Tube Display
Red Tone Reproduction Curve     : (Binary data 2060 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 2060 bytes, use -b option to extract)
Blue Tone Reproduction Curve    : (Binary data 2060 bytes, use -b option to extract)
Image Width                     : 1936
Image Height                    : 2592
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:4:4 (1 1)
Aperture                        : 2.8
Image Size                      : 1936x2592
Megapixels                      : 5.0
Run Time Since Power Up         : 0:52:06
Scale Factor To 35 mm Equivalent: 9.1
Shutter Speed                   : 1/120
Create Date                     : 2019:06:12 17:04:56.493
Date/Time Original              : 2019:06:12 17:04:56.493
Circle Of Confusion             : 0.003 mm
Field Of View                   : 54.4 deg
Focal Length                    : 3.9 mm (35 mm equivalent: 35.0 mm)
Hyperfocal Distance             : 1.60 m
Light Value                     : 9.9*)
(*
result of exiftool is  

Create Date                     : 2019:06:12 17:04:56
Circle Of Confusion             : 0.003 mm

*)
(*debugLog: 
result of exiftool is  Create Date                     : 2019:06:12 17:04:56
Circle Of Confusion             : 0.003 mm
*)
(*debugLog: ---&gt;&gt;&gt; After &lt;&lt;&lt; /Users/mac/Desktop/rockSlab.jpg -------------------*)
(*debugLog: ExifTool Version Number         : 10.36
File Name                       : rockSlab.jpg
Directory                       : /Users/mac/Desktop
File Size                       : 5.9 MB
File Modification Date/Time     : 2019:06:12 17:20:33-04:00
File Access Date/Time           : 2019:06:12 17:46:00-04:00
File Inode Change Date/Time     : 2019:06:12 17:21:08-04:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 4
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : Photos 1.0.1
Modify Date                     : 2019:06:12 17:04:56
Exposure Time                   : 1/120
F Number                        : 2.8
Exposure Program                : Program AE
ISO                             : 100
Exif Version                    : 0221
Date/Time Original              : 2019:06:12 17:04:56
Create Date                     : 2019:06:12 17:04:56
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/120
Aperture Value                  : 2.8
Brightness Value                : 5.52228164
Metering Mode                   : Multi-segment
Flash                           : Auto, Did not fire
Focal Length                    : 3.9 mm
Subject Area                    : 1295 967 699 696
Run Time Flags                  : Valid
Run Time Value                  : 3126374362166
Run Time Epoch                  : 0
Run Time Scale                  : 1000000000
Sub Sec Time Original           : 493
Sub Sec Time Digitized          : 493
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 1936
Exif Image Height               : 2592
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 35 mm
Scene Capture Type              : Standard
Lens Info                       : 3.85mm f/2.8
Lens Make                       : Apple
Lens Model                      : iPhone 4 back camera 3.85mm f/2.8
XMP Toolkit                     : XMP Core 5.4.0
Creator Tool                    : Photos 1.0.1
Date Created                    : 2019:06:12 17:04:56
Current IPTC Digest             : d41d8cd98f00b204e9800998ecf8427e
IPTC Digest                     : d41d8cd98f00b204e9800998ecf8427e
Profile CMM Type                : Lino
Profile Version                 : 2.1.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 1998:02:09 06:49:00
Profile File Signature          : acsp
Primary Platform                : Microsoft Corporation
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : IEC
Device Model                    : sRGB
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : HP
Profile ID                      : 0
Profile Copyright               : Copyright (c) 1998 Hewlett-Packard Company
Profile Description             : sRGB IEC61966-2.1
Media White Point               : 0.95045 1 1.08905
Media Black Point               : 0 0 0
Red Matrix Column               : 0.43607 0.22249 0.01392
Green Matrix Column             : 0.38515 0.71687 0.09708
Blue Matrix Column              : 0.14307 0.06061 0.7141
Device Mfg Desc                 : IEC http://www.iec.ch
Device Model Desc               : IEC 61966-2.1 Default RGB colour space - sRGB
Viewing Cond Desc               : Reference Viewing Condition in IEC61966-2.1
Viewing Cond Illuminant         : 19.6445 20.3718 16.8089
Viewing Cond Surround           : 3.92889 4.07439 3.36179
Viewing Cond Illuminant Type    : D50
Luminance                       : 76.03647 80 87.12462
Measurement Observer            : CIE 1931
Measurement Backing             : 0 0 0
Measurement Geometry            : Unknown
Measurement Flare               : 0.999%
Measurement Illuminant          : D65
Technology                      : Cathode Ray Tube Display
Red Tone Reproduction Curve     : (Binary data 2060 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 2060 bytes, use -b option to extract)
Blue Tone Reproduction Curve    : (Binary data 2060 bytes, use -b option to extract)
Image Width                     : 1936
Image Height                    : 2592
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:4:4 (1 1)
Aperture                        : 2.8
Image Size                      : 1936x2592
Megapixels                      : 5.0
Run Time Since Power Up         : 0:52:06
Scale Factor To 35 mm Equivalent: 9.1
Shutter Speed                   : 1/120
Create Date                     : 2019:06:12 17:04:56.493
Date/Time Original              : 2019:06:12 17:04:56.493
Circle Of Confusion             : 0.003 mm
Field Of View                   : 54.4 deg
Focal Length                    : 3.9 mm (35 mm equivalent: 35.0 mm)
Hyperfocal Distance             : 1.60 m
Light Value                     : 9.9*)
Result:
"R*ch"