Instagram photos and .josn metadata

Started by Mon, May 11, 2020, 10:54:34 AM

Previous topic - Next topic

Mon

Good Morning,
I have discovered Exiftool a couple of days ago and I find it incredible everything that can be done with it.
I want to close my instagram account but without losing the photos that I have uploaded all these years. When Instagram sent me the links to download them, I found that they do not have any type of data to be able to order them in a coherent way (this is where I found Exiftool). There is an attachment called media.json that has all the information of the +3,000 photos in my account. As much as I have tried, I am not able to import this information into the photos. I have searched the forum for similar information that might solve my problem, but none works. It is true that I have been messing around with Exiftool for a short time, but it is a bit difficult for me to work with it (if I have been able to modify the time in other photos that had the time wrong).
Thank you very much, greetings

StarGeek

It's a single json file for all 3,000+ photos?  Ouch.  Exiftool can read the file, but it may make helping a bit difficult.  If you can open the file in a text editor and cut/paste the listing for a single image here, that would be useful.

I'd try and figure it out myself but for some reason Instagram won't let me make an account.  I enter my email address, it says it's already taken.  I try to recover password and it says it can't find an account with that address. 
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

What format is the .json file?  Can you post the start of it?  (say for the first 2 files)

You can write the metadata back to the files easily if you can get the JSON into a format like this:

[{
  "SourceFile": "a.jpg",
  "Description": "this is file a"
},
{
  "SourceFile": "b.jpg",
  "Description": "this is file b"
}]


The SourceFile line is required.  Other lines contain entries for the tags you want to write.

The command would be:

exiftool -json=data.json .

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mon

[/img]
Quote from: StarGeek on May 11, 2020, 12:11:22 PM
It's a single json file for all 3,000+ photos?  Ouch.  Exiftool can read the file, but it may make helping a bit difficult.  If you can open the file in a text editor and cut/paste the listing for a single image here, that would be useful.

I'd try and figure it out myself but for some reason Instagram won't let me make an account.  I enter my email address, it says it's already taken.  I try to recover password and it says it can't find an account with that address.

Thank you very much for the reply,
actually there are two files, one of 2000 photos and another of approximately 1500.
Attached screenshots of .json files, which opens them in a browser.
Thank you very much again.

Mon

Quote from: Phil Harvey on May 11, 2020, 01:11:31 PM
What format is the .json file?  Can you post the start of it?  (say for the first 2 files)

You can write the metadata back to the files easily if you can get the JSON into a format like this:

[{
  "SourceFile": "a.jpg",
  "Description": "this is file a"
},
{
  "SourceFile": "b.jpg",
  "Description": "this is file b"
}]


The SourceFile line is required.  Other lines contain entries for the tags you want to write.

The command would be:

exiftool -json=data.json .

- Phil

The file format is as it appears in the attached file. The photos do not name them as SourceFile, I do not know if the .json file can be modified.
Thank you very much for the reply

Phil Harvey

What you have posted is not a JSON-format file.

JSON is a text-based format, and I need to see the original text.  Use a text editor to cut and paste the start of the file into the forum.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mon

Quote from: Phil Harvey on May 11, 2020, 09:57:17 PM
What you have posted is not a JSON-format file.

JSON is a text-based format, and I need to see the original text.  Use a text editor to cut and paste the start of the file into the forum.

- Phil


Good morning Phil,
The truth is that it is the first time I do something like this and when opening the file it took me to a browser, so I did not try to open it with another program. I leave you attached a screenshot of the folder scheme as it was downloaded from Instagram. The first lines of the file after opening it with TextEdit is as follows:

{"photos": [{"caption": "Capilla de la resurrección", "taken_at": "2013-09-21T12:23:08+00:00", "location": "Skogskyrkogården", "path": "photos/201309/9dd624dfc880dfa0ac50a3fcae446b4c.jpg"}, {"caption": "La capilla del bosque", "taken_at": "2013-09-21T12:22:01+00:00", "location": "Skogskyrkogården", "path": "photos/201309/dcd58219a6365c9aa0d61efeb5fbcff4.jpg"}, {"caption": "", "taken_at": "2013-09-21T12:21:22+00:00", "location": "Skogskyrkogården", "path": "photos/201309/429dad3898db82bbc7d3c26434b91f21.jpg"}, {"caption": "La cura", "taken_at": "2013-09-21T12:20:39+00:00", "location": "Markuskyrkan", "path": "photos/201309/5b8e37e2ff2cf89550217d04b75ab17b.jpg"},

Thank you very much

Phil Harvey

OK, this will work.

Create a copy of the .json file, and edit it in a text editor to do this:

1. Remove this from the start of the file: {"photos":

2. Remove the last "}" from the end of the file.

3. Search and replace all "path" with "SourceFile" (including the quotes).

4. Search and replace all "caption" with "Description" (or whatever tag name you want to write).

5. Search and replace all "taken_at" with "DateTimeOriginal".

6. Search and replace all "location" with whatever tag you want to write this to (or leave it the same to write XMP-iptcCore:Location).

7. Now this is the tricky one:  If your pictures aren't in the same directory hierarchy as specified in the JSON file, you will need to search and replace all "photos/######/ with " (where ###### is any number).

8. "cd" to the directory containing the pictures.

9. Run this command to update your files:

exiftool -json=YOURFILE.json .

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mon

Quote from: Phil Harvey on May 12, 2020, 07:26:25 AM
OK, this will work.

Create a copy of the .json file, and edit it in a text editor to do this:

1. Remove this from the start of the file: {"photos":

2. Remove the last "}" from the end of the file.

3. Search and replace all "path" with "SourceFile" (including the quotes).

4. Search and replace all "caption" with "Description" (or whatever tag name you want to write).

5. Search and replace all "taken_at" with "DateTimeOriginal".

6. Search and replace all "location" with whatever tag you want to write this to (or leave it the same to write XMP-iptcCore:Location).

7. Now this is the tricky one:  If your pictures aren't in the same directory hierarchy as specified in the JSON file, you will need to search and replace all "photos/######/ with " (where ###### is any number).

8. "cd" to the directory containing the pictures.

9. Run this command to update your files:

exiftool -json=YOURFILE.json .

- Phil




Good afternoon Phil,
thank you very much for the reply.
I work on Mac, so I understand I shouldn't use the cd command if I don't put DIR at the end, would it be like this?
I have changed the .json file so it looks like this:

[
 {
   "SourceFile": "5e44662cbeed56aa69bedd75edd71628.jpg",
   "Description": "",
   "DateTimeOriginal": "201321T12: 23: 0800: 00",
   "Location": ""
 },

If I use the exiftool command '-json = media.json' /Users/xxxx/Desktop/xxx

The .json file and the photos are in the same folder.

exiftool returns this to me:


======== /Users/xxxx/Desktop/xxx/5e44662cbeed56aa69bedd75edd71628.jpg
ExifTool Version Number: 11.98
File Name: 5e44662cbeed56aa69bedd75edd71628.jpg
Directory: /Users/xxxx/Desktop/xxx
File Size: 66 kB
File Modification Date / Time: 2020: 05: 10 13: 35: 08 + 02: 00
File Access Date / Time: 2020: 05: 12 16: 04: 31 + 02: 00
File Inode Change Date / Time: 2020: 05: 12 16: 04: 30 + 02: 00
File Permissions: rw-r - r--
File Type: JPEG
File Type Extension: jpg
MIME Type: image / jpeg
JFIF Version: 1.01
Resolution Unit: None
X Resolution: 1
Y Resolution: 1
Current IPTC Digest: 6239cdcb7a011ee41138a65086774dee
Special Instructions: FBMD0f00075c010000ae1c00001c5500001563000027700000eb9900005bfc00008b080100
Image Width: 612
Image Height: 612
Encoding Process: Progressive DCT, Huffman coding
Bits Per Sample: 8
Color Components: 3
Y Cb Cr Sub Sampling: YCbCr4: 2: 0 (2 2)
Image Size: 612x612
Megapixels: 0.375
    1 directories scanned
 1390 image files read
    1 files could not be read


 It does not modify any of the parameters that are in the .json file, any ideas?
Thanks!
M.

Phil Harvey

Quote from: Mon on May 12, 2020, 11:43:23 AM
I understand I shouldn't use the cd command if I don't put DIR at the end

You should "cd" to the directory so the file path matches that in the JSON file.  Otherwise ExifTool won't find the entry in the JSON file.

QuoteIf I use the exiftool command %u2018-json = media.json%u2019 /Users/xxxx/Desktop/xxx

This won't work for a couple of reason.  Try this command after cd-ing to your photo directory:

exiftool -json=media.json .

But your date/time is not the right format in your test JSON file.  Make sure this is correct first.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mon

Quote from: Phil Harvey on May 12, 2020, 02:39:50 PM
Quote from: Mon on May 12, 2020, 11:43:23 AM
I understand I shouldn't use the cd command if I don't put DIR at the end

You should "cd" to the directory so the file path matches that in the JSON file.  Otherwise ExifTool won't find the entry in the JSON file.

QuoteIf I use the exiftool command %u2018-json = media.json%u2019 /Users/xxxx/Desktop/xxx

This won't work for a couple of reason.  Try this command after cd-ing to your photo directory:

exiftool -json=media.json .

But your date/time is not the right format in your test JSON file.  Make sure this is correct first.

- Phil


Goodnight,
I've already managed to change everything. It was a bit difficult because there were several failures here and there that were driving me a little crazy.
Thanks so much for the help.
Greetings.
M.