Instagram media.json How to add them to exif? - metadata

I get my photos out of Instagram and i get zip file with all the photos what i have there but they dosnt have any exif data on them.
The zip file has also a json file called media.json where all these important metadata are. So is there any ways to get the metadata to these photos exif?
Exiftool can import things from files to exif but first i need to know what kind of format the metadata file has to be?
This is a example of a what the instagram media.json file content is and what kind of format:
{
"photos": [
{
"caption": "#nautitaan #kesä2019",
"taken_at": "2019-06-08T03:30:25",
"location": "Jokioinen",
"path": "photos/201906/b65bbda42ba74424a9d7be0c5163f78d.jpg"
},
{
"caption": "#lupanauttia #kesä2019",
"taken_at": "2019-06-07T07:42:38",
"location": "Jokioinen",
"path": "photos/201906/29fb24838136a1e80439ad7dcae00b4f.jpg"
}
]
}
I only need these taken_at entries, all the other things are just plus.

Exiftool can read JSON files. If you run the command exiftool -g1 -a -s on your example JSON file, you will get a list of tag names you can use to copy into your image file. Using your example, the result would be
[JSON] PhotosCaption : #nautitaan #kesä2019, #lupanauttia #kesä2019
[JSON] PhotosLocation : Jokioinen, Jokioinen
[JSON] PhotosPath : photos/201906/b65bbda42ba74424a9d7be0c5163f78d.jpg, photos/201906/29fb24838136a1e80439ad7dcae00b4f.jpg
[JSON] PhotosTaken_at : 2019-06-08T03:30:25, 2019-06-07T07:42:38
The problem now is that because there are multiple items for each tag name. Exiftool tool is very flexible about how it reads numbers for time stamps (see exiftool FAQ 5), so if the first entry is the correct one, you can simply use
exiftool -TagsFromFile FILE.Json "-DateTimeOriginal<PhotosTaken_at" FILE.jpg
If you want to use the second entry, you can use the -listitem option.
exiftool -listitem 1 -TagsFromFile FILE.Json "-DateTimeOriginal<PhotosTaken_at" FILE.jpg
Note that the list index starts at 0, so to get the second item, you would index #1.
To bulk copy, assuming that the base filename of the json file is the same as the image file and in the same directory, you could use this command
exiftool -TagsFromFile %d%f.Json "-DateTimeOriginal<PhotosTaken_at" /path/to/image/files/
This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.

Related

How to watch content from a subfolder of a parent folder using watchman?

I am developing an image uploader by watching files. The images are enclosed in a folder (subfolder) and that folder is being copied in a parent folder that is being watched.
Example:
~/parent/subfolder1/image1.png
~/parent/subfolder2/image2.png
How do I watch these images using the parent folder argument being passed to watchman? or How do I include subfolders?
This is what I have now:
export PARENT_FOLDER = ~/parent/
export UPLOADER_SCRIPT = ~/upload_image.sh
watchman -- trigger $PARENT_FOLDER upload_image -- $UPLOADER_SCRIPT
Inside the upload_image.sh is just an upload function with the image file path as argument
python upload.py image1.png
Use the extended syntax: http://facebook.github.io/watchman/docs/trigger#extended-syntax so that you can define richer matching expressions. For example, this will match any .png file using a glob expression, but you can use any of the expression terms to scope this exactly how you need it:
$ watchman -j <<-EOT
["trigger", "/path/to/parent", {
"name": "upload_image",
"expression": ["match", "**/*.png"],
"command": ["/path/to/upload_image.sh"]
}]
EOT
You may also want to take a look at anyof as a way to combine multiple criteria.

mongoimport: set type for all fields when importing CSV

I have multiple problems with importing a CSV with mongoimport that has a headerline.
Following is the case:
I have a big CSV file with the names of the fields in the first line.
I know you can set this line to use as field names with: --headerline.
I want all field types to be strings, but mongoimport sets the types automatically to what it looks like.
IDs such as 0001 will be turn into 1, which can have bad side effects.
Unfortunately, there is (as far as i know) no way of setting them as string with a single command, but by naming each field and setting it type with
--columnsHaveTypes --fields "name.string(), ... "
When I did that, the next problem appeared.
The headerline (with all field names) got imported as values in a separate document.
So basically, my questions are:
Is there a way of setting all field types as string using the --headerline command ?
Alternative, is there a way to ignore the first line ?
I had this problem when uploading 41 million record CSV file into mongodb.
./mongoimport -d testdb -c testcollection --type csv --columnsHaveTypes -f
"RECEIVEDDATE.date(2006-01-02 15:04:05)" --file location/test.csv
As above we have a command to upload file with data types called '-f' or '--fields' but when we use this command to the file that contain header line, mondodb upload first row as well i.e header lines row then its leads error 'cannot convert to datatype' or upload column names also as data set.
Unfortunately we cannot use '--headerline' command instead of '--fields'.
Here the solutions that I found for this problem.
1)Remove header column and upload using '--fields' command as above command. if you re use linux environment you can use below command to remove first row of the huge file i.e header line.it took 2-3 mints for me.(depending on the machine performance)
sed -i -e "1d" location/test.csv
2)upload the file using '--headerline' command then mongodb uploads the file with its default identified data types.Then open mongodb shell command use testdb then run javascript command that get each record and change it into specific data types.But if you have huge file this will takes time.
found this solution from stackoverflow
db.testcollection.find().forEach( function (x) {
x.RECEIVEDDATE = new Date(x.RECEIVEDDATE ); db.testcollection .save(x);});
If you wanna remove the unnecessary rows that not fit to data type use below command.
mongodb document
'--parseGrace skipRow'
I found a solution, that I am comfortable with
Basically, I wanted to use mongoimport within my Clojure Code to import a CSV file in the DB and do a lot of stuff with it automatically. Due to the above mentioned problems I had to find a workaround, to delete this wrong document.
I did following to "solve" this problem:
To set the types as I wanted, I wrote a function to read the first line, put it in a vector and then used String concatenation to set these as fields.
Turning this: id,name,age,hometown,street
into this: id.string(),name.string(),age.string() etc
Then I used the values from the vector to identify the document with
{ name : "name"
age : "age"
etc : "etc" }
and then deleted it with a simple remving.find() command.
Hope this helps any dealing with the same kind of problem.
https://docs.mongodb.com/manual/reference/program/mongoimport/#example-csv-import-types reads:
MongoDB 3.4 added support for specifying field types. Specify field names and types in the form .() using --fields, --fieldFile, or --headerline.
so your first line within the csv file should have names with types. e.g.:
name.string(), ...
and the mongoimport parameters
--columnsHaveTypes --headerline --file <filename.csv>
As to the question of how to remove the first line, you can employ pipes. mongoimport reads from STDIN if no --file option passed. E.g.:
tail -n+2 <filename.csv> | mongoimport --columnsHaveTypes --fields "name.string(), ... "

Create Array without SourceFile using Exiftool

I would like to use Exiftool to create an array of -Artists for all files in a directory. Using the exiftool command below works but the output is not desirable:
C:\exiftool.exe -Artist Dir
The output looks something like this:
======== E:/File1.jpg
Artist : user1
======== E:/File2.jpg
Artist : user2
1 directories scanned
2 image files read
I would like the output to look something like this:
user1_user2
Or at least a simple array or output like:
user1
user2
To expand upon the answer I posted in the exiftool forums :
exiftool -q -s3 -Artist DIR
This will output each Artist tag on a line by itself, like your second example.
-q - Suppresses normal informational messages. This will suppress the file name listings.
-s3 - Short output format. In this case, the addition of 3 to the option only prints the values of the tag.

Azure Data Factory : Recursive file copy name in the destination

I have data factory that upload daily upload file from on premise into ADLS.
Currently all the files uploaded are using directoryName-GUID as name.
For uploaded file i want to keep the same name as source file , how can i do that ?
I tired the following
"linkedServiceName": "Destination-DataLakeStore-gd6",
"typeProperties": {
"fileName": "{fileName}.csv",
"folderPath": "data/{year}/{month}/{day}",
"format": {
"type": "TextFormat",
"columnDelimiter": ","
},
"partitionedBy"
But instead of substituting the filename it is output the file as {fileName}.csv
What are my options here ?
Do not specify filename in the datasets. Your current config actually indicate naming the file as "{fileName}.csv".
A related note: if you just want to copy files as-is without parsing it, you can skip the format setting for both input and output datasets (or keep them exactly the same).

How to change XMP Toolkit MetaData in Image

i am using exiftool to change meta data in an image. Here is a mwe:
#!/bin/bash
EXIF=exiftool
$EXIF -LensModel="Bubble Teleskop on Marsmission" $1
This is working with many entries, Model, Longitude, Latitude, etc.
But now i try to change the "XMP Toolkit" with
$EXIF -xmptoolkit='Paint' $1
or so, but every time i try to change the string, only the original name and version of the exiftool version is inserted.
Some ideas?
Thanks
Put all your changes on a single command:
$EXIF -Lens="XSD II 50" -xmptoolkit='Paint' -LensMake="Tamron" $1
Exiftool can execute multiple changes in a single command.
XMPToolkit is always going to get updated whenever you change some XMP data.
You can also update XMPToolkit as the last item in your batch or add -tagsfromfile # -XMPToolkit to your commands after the command in which you set XMPToolkit. The tagsfromfile # option will recopy any tags that appear after it back into the file.