How to read some info from a specific file?

Started by sinus, March 14, 2017, 09:48:24 AM

Previous topic - Next topic

sinus

If I use the demo 6, I can get the images, very quickly and it works great.  :D

See attachement.

I can see there the IDs from each image.

I see now, that ID 422612 is the correct image.

Now I want more infos from this specific image, like headline, city, width and height.

For this I must take this ID and work with some endpoints and create another script?

Like in WinWrap, as soon as I have some basic examples here, I am maybe able to understand better and work with it.  8)

And yes, I know and am very thankful, when IMatch2017 comes out, Mario will deliver some scripts, what I will like!  :D
But maybe I could meanwhile a bit lern, how to read some infos from images.
Best wishes from Switzerland! :-)
Markus

Mario

Use the v1/files endpoint to retrieve data about files.

If you use jQuery, you can do

'v1/files', {
    id: 422612,
    fields: 'id,filename,size'
}


See the documentation for /files for all details.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Best wishes from Switzerland! :-)
Markus

sinus

Since all other stuff at the moment is too difficult for me, I tried, if at least something works.

Here a try for very poor people;)
Ah, yes, Mario, if you want have a bit fun and some rofls  ;D, you can read this also!  :D :D

1) first I went to the endpoints and looked for files
2) I tried the first example (attachement 1)
3) after click I go this (attach 2)
hmm, I thought, not good, maybe the id 1-20 are not good for my db?

4) I then clicked with the right mousebutton on "Element untersuchen" (the last entry in the list) and got this (attach 3)
5) I copied this lines (blue) and changed the id 1-20 with the id, what I knew from another search (attach 4)

This line I putted into the html from Demo6 and got there a link.
6) I clicked on that link and guess? Wow, attach 5 are my data from my single image (a lot of info)

So, a small success, even it is in the right direction.  ;D

I know now, I can do something, how I must do it correct, I have to lern.
Best wishes from Switzerland! :-)
Markus

Mario

Just replace the 1-20 in the URL with 422612

Your database just has no files with the ids 1 to 20. This is normal. You just need to figure out a working id to make the example URL work.

If you don't use the URL but you do a jQuery Ajax call (which is the easiest way to do it from JavaScript, see the demos in the developer center). Its always the same, whether you want info for one file or multiple

                $.ajax({
                    method: 'GET',
                    url: 'http://your-pc:8081/v1/files',
                    data: {
                        auth_token: 'YOUR AUTH TOKEN',
                        id: '422612',
                        fields: 'id,filename',
                        tagTitle:'title'
                    }
                    }).then(function(response) {
                        alert(JSON.stringify(response));
                    });


You need to set the url and the auth_token to match your machine.
See the authentication demo to see how to authenticate with IMWS and to get the auth_token. IMWS does not allow you to retrieve data about files without an auth_token (security feature).

If you update the url and use the auth_token you get back from the /authenticate endpoint, the above code fragment retrieves the id, file name and the title metadata tag. It displays the RAW data returned in a message box.

Just play around with it. Use the demos on the web site. Run them in your browser and learn how you can use the debugging tools (<F12> key!). Then you can step through the code and see how everything works.


-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook