As suggested by @plegall it would be very useful to be able to provide a list of image Ids instead of only one when calling the API method pwg.images.getInfo. For example, on mobile apps:
As suggested by @plegall it would be very useful to be able to provide a list of image Ids instead of only one when calling the API method `pwg.images.getInfo`. For example, on mobile apps:
- this method is called many times for displaying albums at start. See e.g. https://github.com/Piwigo/Piwigo-Mobile/issues/228
- this method would also have to be called many times for sorting images in an album according to their rating scores. See e.g. https://github.com/Piwigo/Piwigo-Mobile/issues/287
<!-- github-sync-id:411211042 -->
I'm a bit confused, you're asking for image_idas list on pwg.categories.getImages but I was initially suggesting that for method pwg.images.getInfo. Furthermore, pwg.categories.getImages has no image_id parameter. I'll do as if you asked for pwg.images.getInfo :-)
I'm a bit confused, you're asking for `image_id`as list on `pwg.categories.getImages` but I was initially suggesting that for method `pwg.images.getInfo`. Furthermore, `pwg.categories.getImages` has no `image_id` parameter. I'll do as if you asked for `pwg.images.getInfo` :-)
<!-- github-comment-id:505897275 -->
Oups! I think that I have mixed things. Sorry for that. pwg.images.getInfo is called many times before displaying a list of albums (to show the albums thumbnails) and before allowing a copy/move/delete a selection of images (for example).
Oups! I think that I have mixed things. Sorry for that.
`pwg.images.getInfo` is called many times before displaying a list of albums (to show the albums thumbnails) and before allowing a copy/move/delete a selection of images (for example).
<!-- github-comment-id:505966705 -->
I'm currently working on pwg.images.getInfo to make it compatible with a list of image ids. Even if it might be an interesting evolution, wouldn't it be even better for you to have the right thumbnail URL directly returned by pwg.categories.getList ? Currently it returns a tn_url. I suppose this is not what you need (or you wouldn't call pwg.images.getInfo). Which url would you need from pwg.categories.getList?
I'm currently working on `pwg.images.getInfo` to make it compatible with a list of image ids. Even if it might be an interesting evolution, wouldn't it be even better for you to have the right thumbnail URL directly returned by `pwg.categories.getList` ? Currently it returns a tn_url. I suppose this is not what you need (or you wouldn't call `pwg.images.getInfo`). Which url would you need from `pwg.categories.getList`?
<!-- github-comment-id:506282796 -->
Today, the app uses the image of medium size for displaying albums.
I've just looked at the API description and realised that there is already a parameter thumbnail_size. Obviously I should have used it with the medium value. I will give it a try.
As for pwg.images.getInfo, the option to provide a list of image IDs will be extremely useful anyway.
PS: It might be useful to describe the faked_by_community parameter on the API browser.
Today, the app uses the image of medium size for displaying albums.
I've just looked at the API description and realised that there is already a parameter `thumbnail_size`. Obviously I should have used it with the `medium` value. I will give it a try.
As for `pwg.images.getInfo`, the option to provide a list of image IDs will be extremely useful anyway.
PS: It might be useful to describe the `faked_by_community` parameter on the API browser.
<!-- github-comment-id:506359580 -->
I've made some tests with the iOS app and I see this list of HTTP requests:
POST /ws.php?format=json&method=reflection.getMethodList
POST /ws.php?format=json&method=pwg.session.login
POST /ws.php?format=json&method=pwg.session.getStatus
POST /ws.php?format=json&method=pwg.categories.getList
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2015/11/20/20151120152257-67f693a3-me.jpg
GET /uploads/2016/03/22/20160322140115-11ee4d46.png
GET /_datas/i/uploads/0/s/g/59953-me.jpg
GET /_datas/i/uploads/2017/04/15/20170415145705-14c9b5a0-me.png
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2015/02/08/20150208143057-378c9fb8-me.jpg
GET /_datas/i/uploads/2013/10/30/20131030112533-f0c320de-me.jpg
GET /_datas/i/uploads/2014/07/12/20140712092438-1ae4d7f2-me.jpg
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2013/11/13/20131113154241-e5738e42-me.png
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2013/10/07/20131007212604-c4dce435-me.jpg
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2018/07/03/20180703142944-371a570d-me.png
So it seems obvious to me that the app makes a request on pwg.images.getInfo only to get the Medium url. As you wrote earlier, use parameter thumbnail_size=medium on pwg.categories.getList will save you a lot of requests :-)
Now about giving the possibility to have a list of image_id on pwg.images.getInfo, I've started working on it but it's quite complicated. This method was designed to fetch all information related to a photo to build the equivalent of the page of the photo. For example it includes the list of user comments, with paging option (you can get the 4th page of comments).
If we have a list of image_id, sending the user comments does not seem relevant anymore. How should the method behave when asked for the 2nd page of comments on 10 photos?
For me, it means if a remote script asks for a list of image_id on pwg.images.getInfo, then we don't return the user comments. Meaning we would have a different output depending on the number of image_id requested.
Can you give an example of what properties would be interesting for you?
I've made some tests with the iOS app and I see this list of HTTP requests:
```
POST /ws.php?format=json&method=reflection.getMethodList
POST /ws.php?format=json&method=pwg.session.login
POST /ws.php?format=json&method=pwg.session.getStatus
POST /ws.php?format=json&method=pwg.categories.getList
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2015/11/20/20151120152257-67f693a3-me.jpg
GET /uploads/2016/03/22/20160322140115-11ee4d46.png
GET /_datas/i/uploads/0/s/g/59953-me.jpg
GET /_datas/i/uploads/2017/04/15/20170415145705-14c9b5a0-me.png
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2015/02/08/20150208143057-378c9fb8-me.jpg
GET /_datas/i/uploads/2013/10/30/20131030112533-f0c320de-me.jpg
GET /_datas/i/uploads/2014/07/12/20140712092438-1ae4d7f2-me.jpg
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2013/11/13/20131113154241-e5738e42-me.png
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2013/10/07/20131007212604-c4dce435-me.jpg
POST /ws.php?format=json&method=pwg.images.getInfo
GET /_datas/i/uploads/2018/07/03/20180703142944-371a570d-me.png
```
So it seems obvious to me that the app makes a request on `pwg.images.getInfo` only to get the Medium url. As you wrote earlier, use parameter thumbnail_size=medium on `pwg.categories.getList` will save you a lot of requests :-)
Now about giving the possibility to have a list of `image_id` on `pwg.images.getInfo`, I've started working on it but it's quite complicated. This method was designed to fetch all information related to a photo to build the equivalent of the page of the photo. For example it includes the list of user comments, with paging option (you can get the 4th page of comments).
If we have a list of `image_id`, sending the user comments does not seem relevant anymore. How should the method behave when asked for the 2nd page of comments on 10 photos?
For me, it means if a remote script asks for a list of `image_id` on `pwg.images.getInfo`, then we don't return the user comments. Meaning we would have a different output depending on the number of `image_id` requested.
Can you give an example of what properties would be interesting for you?
<!-- github-comment-id:506766002 -->
The code now requests the medium size and it saves a lot of requests. Great!
Do you know if the version 2.7 of Piwigo already provided the thumbnail_size parameter?
As for pwg.images.getInfo, the app calls it a lot when the user wants to copy, move, delete or share a selection of images (comments not needed at that point). It also calls it when the app displays an image full screen so that the user can then copy, move, delete or share the image.
In the future, I would like to also let users sort/filter images according to rates, tags or geo-localisations. For coding that options, it would be nice that pwg.categories.getImages provides more data.
The code now requests the medium size and it saves a lot of requests. Great!
Do you know if the version 2.7 of Piwigo already provided the `thumbnail_size` parameter?
As for `pwg.images.getInfo`, the app calls it a lot when the user wants to copy, move, delete or share a selection of images (comments not needed at that point). It also calls it when the app displays an image full screen so that the user can then copy, move, delete or share the image.
In the future, I would like to also let users sort/filter images according to rates, tags or geo-localisations. For coding that options, it would be nice that `pwg.categories.getImages` provides more data.
<!-- github-comment-id:507016714 -->
The thumbnail_sizeparameter was added for Piwigo 2.8, see #410 . A few weeks before the release of Piwigo 2.10, it's perfectly OK to require Piwigo 2.8 (which was released 3 years ago)
As for pwg.images.getInfo, the app calls it a lot when the user wants to copy, move, delete or share a selection of images (comments not needed at that point).
And what do you need from pwg.images.getInfo to perform these tasks?
It also calls it when the app displays an image full screen so that the user can then copy, move, delete or share the image.
Yes, but it's only for a single image_id, right?
In the future [...] it would be nice that pwg.categories.getImages provides more data.
No problem, you'll tell what the Piwigo app on iOS need :-)
The `thumbnail_size`parameter was added for Piwigo 2.8, see #410 . A few weeks before the release of Piwigo 2.10, it's perfectly OK to require Piwigo 2.8 (which was released 3 years ago)
> As for pwg.images.getInfo, the app calls it a lot when the user wants to copy, move, delete or share a selection of images (comments not needed at that point).
And what do you need from `pwg.images.getInfo` to perform these tasks?
> It also calls it when the app displays an image full screen so that the user can then copy, move, delete or share the image.
Yes, but it's only for a single `image_id`, right?
> In the future [...] it would be nice that pwg.categories.getImages provides more data.
No problem, you'll tell what the Piwigo app on iOS need :-)
<!-- github-comment-id:507213337 -->
The next release of the iOS app will request Piwigo 2.8. Thank you.
To copy, move and delete images, the app needs to know to which categories the images belong to. pwg.categories.getImages returns one category ID while pwg.images.getInfo returns the complete list of category IDs. I attach below screenshots of Xcode for an image belonging to two albums. The categoryIds array contains 1 element after calling pwg.categories.getImages and 2 elements after calling pwg.images.getInfo.
I do not remember why I need to call pwg.images.getInfo` before sharing. I must investigate.
The next release of the iOS app will request Piwigo 2.8. Thank you.
To copy, move and delete images, the app needs to know to which categories the images belong to. `pwg.categories.getImages` returns one category ID while `pwg.images.getInfo` returns the complete list of category IDs. I attach below screenshots of Xcode for an image belonging to two albums. The categoryIds array contains 1 element after calling `pwg.categories.getImages` and 2 elements after calling `pwg.images.getInfo`.
<img width="415" alt="Screenshot 2019-07-01 at 22 08 00" src="https://user-images.githubusercontent.com/7103032/60463796-31987280-9c4d-11e9-8489-737408a57edc.png">
<img width="415" alt="Screenshot 2019-07-01 at 22 07 40" src="https://user-images.githubusercontent.com/7103032/60463805-39581700-9c4d-11e9-9b5b-53b065cfd108.png">
I do not remember why I need to call pwg.images.getInfo` before sharing. I must investigate.
<!-- github-comment-id:507412282 -->
In addition, the iOS app would need the rate_score value of a series of images in order to be able to display it in legends of images shown in a Discover/Best rated page, as on the web interface.
In addition, the iOS app would need the `rate_score` value of a series of images in order to be able to display it in legends of images shown in a Discover/Best rated page, as on the web interface.
<!-- github-comment-id:513576720 -->
From which API method would you need the rate_score value?
As for the original request of this issue, if you only need the list of albums related to a list of photos, I think it would be more efficient and safer to have a new method pwg.images.getCategories:
avoid any regression bug on pwg.images.getInfo
possibility to mark it as "admin only" and list all related albums, not only those visible to the user
possibility to add it on a 2.10.1 version
Anyway, can you give me more details about why you need to have the list of albums related to a photo before you move/delete this photo? With more details I may give a smarter advice and avoid creating extra API methods ;-)
From which API method would you need the `rate_score` value?
As for the original request of this issue, if you only need the list of albums related to a list of photos, I think it would be more efficient and safer to have a new method `pwg.images.getCategories`:
- avoid any regression bug on `pwg.images.getInfo`
- possibility to mark it as "admin only" and list all related albums, not only those visible to the user
- possibility to add it on a 2.10.1 version
Anyway, can you give me more details about why you need to have the list of albums related to a photo before you move/delete this photo? With more details I may give a smarter advice and avoid creating extra API methods ;-)
<!-- github-comment-id:521238701 -->
The iOS app uses the method pwg.categories.getImages to retrieve the list of images belonging to a category or the lists of most visited, best rated and recent images.
For each image, this method returns an array categories containing only one category ID, the one used to call the method. It does not return the complete list of category IDs and the app does not know if images belong to other albums of the logged user. This is not a problem for showing the images, but…
When the user selects a number of images to move, copy or delete them, the app must first call the method pwg.images.getInfo for each image to determine what to do. For example, if an image belongs to two albums and an admin user wants to delete it, after calling pwg.images.getInfo, the app can propose to remove it from the current album or to delete it from the database. If a Community user with upload rights wants to copy or move an image belonging to several albums to another album, the app changes the list of categories of the image correctly (e.g. keep the two other albums to which it already belongs to).
My first question is therefore: would it be possible to get the complete list of category IDs in which an image belongs to with the method pwg.categories.getImages (for the current user)?
The method pwg.categories.getImages returns the 'hit' of images and this allows the iOS app to display the number of hits below the images of the "Most visited" album. The same cannot be done with the "Best rated" album because the 'rating_score' of the returned images is not provided by pwg.categories.getImages.
My second question is therefore: would it be possible to also get the 'rating_score' of images with the method pwg.categories.getImages?
I hope this clarifies a bit things. There is no need to modify pwg.images.getInfo if the above questions can be answered ;-)
The iOS app uses the method `pwg.categories.getImages` to retrieve the list of images belonging to a category or the lists of most visited, best rated and recent images.
For each image, this method returns an array `categories` containing only one category ID, the one used to call the method. It does not return the complete list of category IDs and the app does not know if images belong to other albums of the logged user. This is not a problem for showing the images, but…
When the user selects a number of images to move, copy or delete them, the app must first call the method `pwg.images.getInfo` for each image to determine what to do. For example, if an image belongs to two albums and an admin user wants to delete it, after calling `pwg.images.getInfo`, the app can propose to remove it from the current album or to delete it from the database. If a Community user with upload rights wants to copy or move an image belonging to several albums to another album, the app changes the list of categories of the image correctly (e.g. keep the two other albums to which it already belongs to).
My first question is therefore: would it be possible to get the complete list of category IDs in which an image belongs to with the method `pwg.categories.getImages` (for the current user)?
The method `pwg.categories.getImages` returns the 'hit' of images and this allows the iOS app to display the number of hits below the images of the "Most visited" album. The same cannot be done with the "Best rated" album because the 'rating_score' of the returned images is not provided by `pwg.categories.getImages`.
My second question is therefore: would it be possible to also get the 'rating_score' of images with the method `pwg.categories.getImages`?
I hope this clarifies a bit things. There is no need to modify `pwg.images.getInfo` if the above questions can be answered ;-)
<!-- github-comment-id:521415693 -->
Am I right that at the end the idea to modify pwg.images.getInfo to have parameter 'image_id' as a list was cancelled?
It's a pitty if so. May be I missed something in Piwigo Web API, but I often need to get the list of images (sometimes from different categories) to embed them in the external to Piwigo web pages of the web site (Piwigo is a part of it).
For the moment the only way I found is to get images one by one via pwg.images.getInfo. So, I have dozens of requests instead of having only one if 'image_id' would be a list of ids.
Am I right that at the end the idea to modify pwg.images.getInfo to have parameter 'image_id' as a list was cancelled?
It's a pitty if so. May be I missed something in Piwigo Web API, but I often need to get the list of images (sometimes from different categories) to embed them in the external to Piwigo web pages of the web site (Piwigo is a part of it).
For the moment the only way I found is to get images one by one via pwg.images.getInfo. So, I have dozens of requests instead of having only one if 'image_id' would be a list of ids.
<!-- github-comment-id:755632638 -->
This issue is not closed and I believe that we all agree with you that we need a method to collect the parameters of a list of images. But which ones...
The method pwg.categories.getImages returns: id, categories, name, comment, hit, file, date_creation, date_available, width, height, element_url, derivatives, and page_url:
categories is an array containing only the cat_id of the fetched category. So it does not allow to know whether images belong to other albums. The iOS app therefore calls several times pwg.images.getInfos to determine what to do when the user wants to delete, remove from album, move or copy a selection of images to another album.
The favorites can be identified after calling pwg.users.favorites.getList but the rating_score can only be retrieved from a series of calls to pwg.images.getInfos (to my knowledge).
The new method which we may call pwg.images.getListInfos should provide the complete list of cat_ids each image belongs to and the rating_score for the reasons given above. I would also add the GPS coordinates so that we can easily present a map showing where a selection of images was taken. What else? Which other parameters should be returned?
To my opinion, the creation of pwg.images.getListInfos implies the creation of pwg.images.setListInfos. What are your thoughts?
This issue is not closed and I believe that we all agree with you that we need a method to collect the parameters of a list of images. But which ones...
The method `pwg.categories.getImages` returns: _id_, _categories_, _name_, _comment_, _hit_, _file_, _date_creation_, _date_available_, _width_, _height_, _element_url_, _derivatives_, and _page_url_:
- _categories_ is an array containing only the _cat_id_ of the fetched category. So it does not allow to know whether images belong to other albums. The iOS app therefore calls several times `pwg.images.getInfos` to determine what to do when the user wants to delete, remove from album, move or copy a selection of images to another album.
- The favorites can be identified after calling `pwg.users.favorites.getList` but the _rating_score_ can only be retrieved from a series of calls to `pwg.images.getInfos` (to my knowledge).
The method `pwg.images.getInfo` returns: _author_, _level_, _tags_, _added_by_, _rating_score_, _rates_, _representative_ext_, _filesize_, _md5sum_, _date_metadata_update_, _lastmodified_, _rotation_, _latitude_, _longitude_, _comments_, _comments_paging_, and _coi_.
The new method which we may call `pwg.images.getListInfos` should provide the complete list of _cat_ids_ each image belongs to and the _rating_score_ for the reasons given above. I would also add the GPS coordinates so that we can easily present a map showing where a selection of images was taken. What else? Which other parameters should be returned?
To my opinion, the creation of `pwg.images.getListInfos` implies the creation of `pwg.images.setListInfos`. What are your thoughts?
<!-- github-comment-id:756301227 -->
I do not know how does it look from Piwigo developers' side, but I think that it will be better do not change pwg.images.getInfo behaviour and parameters' list to keep backward compatibility.
So, introducing pwg.images.getListInfos is a good idea for me. I need at list the following parameters to be returned by this proposed method: author, date_metadata_update, page_url, comments, derivatives, cat_ids.
For my personal use rating_score, latitude, longitude are not strictly needed, but I understand that they could be useful. And as most of the returned parameters could be the optional ones that should not be a problem, I hope.
As for creation of the companion method pwg.images.setListInfos I'm not sure. Lets say that I do not have an opinion on this subject yet :)
I do not know how does it look from Piwigo developers' side, but I think that it will be better do not change `pwg.images.getInfo` behaviour and parameters' list to keep backward compatibility.
So, introducing `pwg.images.getListInfos` is a good idea for me. I need at list the following parameters to be returned by this proposed method: _author, date_metadata_update, page_url, comments, derivatives, cat_ids_.
For my personal use _rating_score, latitude, longitude_ are not strictly needed, but I understand that they could be useful. And as most of the returned parameters could be the optional ones that should not be a problem, I hope.
As for creation of the companion method `pwg.images.setListInfos` I'm not sure. Lets say that I do not have an opinion on this subject yet :)
<!-- github-comment-id:756326265 -->
The method pwg.categories.getImages returns: id, categories, name, comment, hit, file, date_creation, date_available, width, height, element_url, derivatives, and page_url:
categories is an array containing only the cat_id of the fetched category. So it does not allow to know whether images belong to other albums. The iOS app therefore calls several times pwg.images.getInfos to determine what to do when the user wants to delete, remove from album, move or copy a selection of images to another album.
The list of category ids returned by pwg.images.getInfo is filtered by permission. You can't rely on it to know if the image belongs to another album. What's the status on this?
(I see on Piwigo.com a client who performs thousands of pwg.images.getInfo each day so I wonder how we could do better with a list image ids...
@EddyLB
> The method pwg.categories.getImages returns: id, categories, name, comment, hit, file, date_creation, date_available, width, height, element_url, derivatives, and page_url:
>
> categories is an array containing only the cat_id of the fetched category. So it does not allow to know whether images belong to other albums. The iOS app therefore calls several times pwg.images.getInfos to determine what to do when the user wants to delete, remove from album, move or copy a selection of images to another album.
The list of category ids returned by `pwg.images.getInfo` is filtered by permission. You can't rely on it to know if the image belongs to another album. What's the status on this?
(I see on Piwigo.com a client who performs thousands of `pwg.images.getInfo` each day so I wonder how we could do better with a list image ids...
<!-- github-comment-id:2694060992 -->
Up to the version 3.2.5 available today on the App Store, the iOS app calls pwg.images.getInfo:
before editing the parameters of a single image (title, author, creation_date, tags, privacy, comment) if an incomplete set of data is in cache for that image. The modified parameters are saved with pwg.images.setInfo.
for copying one or a selection of images to an album. It calls the method a number of times which depends whether on image data in cache. If, for example, the selection of N images belongs to a freshly loaded album, it calls the method N times to know to which albums each image belongs to (for that user of course). Then it calls pwg.images.setInfo N times with an updated categories value.
for moving one or a selection of images to an album. It does a similar job. The difference resides in the value of the categories parameter.
for deleting one or a selection of images from an album. In that case, once all the image data is known, the app can determine which images should be removed (up to N calls of pwg.images.setInfo) and which one should be deleted with pwg.images.delete (a single call for a set of image_ids).
for copying a set of images to an album instead of uploading them, i.e. when the user requested an upload of an image already uploaded (same technique as for copying).
for finishing the upload of an image with the old method pwg.images.upload which has a bug preventing the naming of the image. This is now rare because pwg.images.uploadAsync exists for a several years.
What is not implemented yet is a menu allowing to switch to one of the albums an image belongs to. This functionality is highly demanded, especially by those using the search bar. It will be available soon.
Another thing which is not implemented is a "true" Discover / Best rated album because rating_score is not provided by pwg.categories.getImages. To display that album correctly, the app should systematically call pwg.images.getInfo for all the images for which it has an incomplete set of data.
The same applies to comments (less demanded).
I am actually preparing a new version 3.3 which will reduce the number of calls to pwg.images.getInfo (and speed up some actions) by exploiting pwg.images.setCategory (you can test it from TestFlight). A selection of images will be:
copied to an album with a single call (associate)
moved from an album to another one with two calls (associate and dissociate)
removed from an album by calling once pwg.images.setCategory.
Of course, for all actions, the app does the job to associate/dissociate images to albums internally to keep the cache up to date because pwg.images.setCategorydoes not return the album data concerned by the requested action (same issue as for a few other methods).
To come back to pwg.images.getInfo, we need an efficient solution for retrieving the cat_ids of a selection of images, but also rates, comment_post, comments, as the Piwigo would do for the user having opening the session. Why not for example to create pwg.images.getCategories, pwg.images.getRatingScore or pwg.images.getRates, and pwg.images.getComments?
Of course, it would also be great to find a solution for changing the parameters of a set of images because pwg.images.setInfo only applies to a single image.
I hope this answers your question.
PS: In the cache, each server contains users, tags and images (image files and properties are shared by users, same for tags). To apply access rights, each album belongs to a single user and contains images. Locations, i.e. place names corresponding to GPS coordinates, are shared by all servers. As for upload requests, they belong to one user and are associated to tags.
Hi @plegall
Up to the version 3.2.5 available today on the App Store, the iOS app calls `pwg.images.getInfo`:
- before editing the parameters of a single image (`title`, `author`, `creation_date`, `tags`, `privacy`, `comment`) if an incomplete set of data is in cache for that image. The modified parameters are saved with `pwg.images.setInfo`.
- for copying one or a selection of images to an album. It calls the method a number of times which depends whether on image data in cache. If, for example, the selection of N images belongs to a freshly loaded album, it calls the method N times to know to which albums each image belongs to (for that user of course). Then it calls `pwg.images.setInfo` N times with an updated `categories` value.
- for moving one or a selection of images to an album. It does a similar job. The difference resides in the value of the `categories` parameter.
- for deleting one or a selection of images from an album. In that case, once all the image data is known, the app can determine which images should be removed (up to N calls of `pwg.images.setInfo`) and which one should be deleted with `pwg.images.delete` (a single call for a set of `image_ids`).
- for copying a set of images to an album instead of uploading them, i.e. when the user requested an upload of an image already uploaded (same technique as for copying).
- for finishing the upload of an image with the old method `pwg.images.upload` which has a bug preventing the naming of the image. This is now rare because `pwg.images.uploadAsync` exists for a several years.
- What is not implemented yet is a menu allowing to switch to one of the albums an image belongs to. This functionality is highly demanded, especially by those using the search bar. It will be available soon.
- Another thing which is not implemented is a "true" _Discover / Best rated_ album because `rating_score` is not provided by `pwg.categories.getImages`. To display that album correctly, the app should systematically call `pwg.images.getInfo` for all the images for which it has an incomplete set of data.
- The same applies to comments (less demanded).
I am actually preparing a new version 3.3 which will reduce the number of calls to `pwg.images.getInfo` (and speed up some actions) by exploiting `pwg.images.setCategory` (you can test it from TestFlight). A selection of images will be:
- copied to an album with a single call (`associate`)
- moved from an album to another one with two calls (`associate` and `dissociate`)
- removed from an album by calling once `pwg.images.setCategory`.
Of course, for all actions, the app does the job to associate/dissociate images to albums internally to keep the cache up to date because `pwg.images.setCategory` [does not return the album data concerned by the requested action](https://github.com/Piwigo/Piwigo/issues/1735) (same issue as for a few other methods).
To come back to `pwg.images.getInfo`, we need an efficient solution for retrieving the `cat_ids` of a selection of images, but also `rates`, `comment_post`, `comments`, as the Piwigo would do for the user having opening the session. Why not for example to create `pwg.images.getCategories`, `pwg.images.getRatingScore` or `pwg.images.getRates`, and `pwg.images.getComments`?
Of course, it would also be great to find a solution for changing the parameters of a set of images because `pwg.images.setInfo` only applies to a single image.
I hope this answers your question.
PS: In the cache, each server contains users, tags and images (image files and properties are shared by users, same for tags). To apply access rights, each album belongs to a single user and contains images. Locations, i.e. place names corresponding to GPS coordinates, are shared by all servers. As for upload requests, they belong to one user and are associated to tags.
<!-- github-comment-id:2695631194 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
As suggested by @plegall it would be very useful to be able to provide a list of image Ids instead of only one when calling the API method
pwg.images.getInfo. For example, on mobile apps:I'm a bit confused, you're asking for
image_idas list onpwg.categories.getImagesbut I was initially suggesting that for methodpwg.images.getInfo. Furthermore,pwg.categories.getImageshas noimage_idparameter. I'll do as if you asked forpwg.images.getInfo:-)Oups! I think that I have mixed things. Sorry for that.
pwg.images.getInfois called many times before displaying a list of albums (to show the albums thumbnails) and before allowing a copy/move/delete a selection of images (for example).I'm currently working on
pwg.images.getInfoto make it compatible with a list of image ids. Even if it might be an interesting evolution, wouldn't it be even better for you to have the right thumbnail URL directly returned bypwg.categories.getList? Currently it returns a tn_url. I suppose this is not what you need (or you wouldn't callpwg.images.getInfo). Which url would you need frompwg.categories.getList?Today, the app uses the image of medium size for displaying albums.
I've just looked at the API description and realised that there is already a parameter
thumbnail_size. Obviously I should have used it with themediumvalue. I will give it a try.As for
pwg.images.getInfo, the option to provide a list of image IDs will be extremely useful anyway.PS: It might be useful to describe the
faked_by_communityparameter on the API browser.I've made some tests with the iOS app and I see this list of HTTP requests:
So it seems obvious to me that the app makes a request on
pwg.images.getInfoonly to get the Medium url. As you wrote earlier, use parameter thumbnail_size=medium onpwg.categories.getListwill save you a lot of requests :-)Now about giving the possibility to have a list of
image_idonpwg.images.getInfo, I've started working on it but it's quite complicated. This method was designed to fetch all information related to a photo to build the equivalent of the page of the photo. For example it includes the list of user comments, with paging option (you can get the 4th page of comments).If we have a list of
image_id, sending the user comments does not seem relevant anymore. How should the method behave when asked for the 2nd page of comments on 10 photos?For me, it means if a remote script asks for a list of
image_idonpwg.images.getInfo, then we don't return the user comments. Meaning we would have a different output depending on the number ofimage_idrequested.Can you give an example of what properties would be interesting for you?
The code now requests the medium size and it saves a lot of requests. Great!
Do you know if the version 2.7 of Piwigo already provided the
thumbnail_sizeparameter?As for
pwg.images.getInfo, the app calls it a lot when the user wants to copy, move, delete or share a selection of images (comments not needed at that point). It also calls it when the app displays an image full screen so that the user can then copy, move, delete or share the image.In the future, I would like to also let users sort/filter images according to rates, tags or geo-localisations. For coding that options, it would be nice that
pwg.categories.getImagesprovides more data.The
thumbnail_sizeparameter was added for Piwigo 2.8, see #410 . A few weeks before the release of Piwigo 2.10, it's perfectly OK to require Piwigo 2.8 (which was released 3 years ago)And what do you need from
pwg.images.getInfoto perform these tasks?Yes, but it's only for a single
image_id, right?No problem, you'll tell what the Piwigo app on iOS need :-)
The next release of the iOS app will request Piwigo 2.8. Thank you.
To copy, move and delete images, the app needs to know to which categories the images belong to.
pwg.categories.getImagesreturns one category ID whilepwg.images.getInforeturns the complete list of category IDs. I attach below screenshots of Xcode for an image belonging to two albums. The categoryIds array contains 1 element after callingpwg.categories.getImagesand 2 elements after callingpwg.images.getInfo.I do not remember why I need to call pwg.images.getInfo` before sharing. I must investigate.
In addition, the iOS app would need the
rate_scorevalue of a series of images in order to be able to display it in legends of images shown in a Discover/Best rated page, as on the web interface.From which API method would you need the
rate_scorevalue?As for the original request of this issue, if you only need the list of albums related to a list of photos, I think it would be more efficient and safer to have a new method
pwg.images.getCategories:pwg.images.getInfoAnyway, can you give me more details about why you need to have the list of albums related to a photo before you move/delete this photo? With more details I may give a smarter advice and avoid creating extra API methods ;-)
The iOS app uses the method
pwg.categories.getImagesto retrieve the list of images belonging to a category or the lists of most visited, best rated and recent images.For each image, this method returns an array
categoriescontaining only one category ID, the one used to call the method. It does not return the complete list of category IDs and the app does not know if images belong to other albums of the logged user. This is not a problem for showing the images, but…When the user selects a number of images to move, copy or delete them, the app must first call the method
pwg.images.getInfofor each image to determine what to do. For example, if an image belongs to two albums and an admin user wants to delete it, after callingpwg.images.getInfo, the app can propose to remove it from the current album or to delete it from the database. If a Community user with upload rights wants to copy or move an image belonging to several albums to another album, the app changes the list of categories of the image correctly (e.g. keep the two other albums to which it already belongs to).My first question is therefore: would it be possible to get the complete list of category IDs in which an image belongs to with the method
pwg.categories.getImages(for the current user)?The method
pwg.categories.getImagesreturns the 'hit' of images and this allows the iOS app to display the number of hits below the images of the "Most visited" album. The same cannot be done with the "Best rated" album because the 'rating_score' of the returned images is not provided bypwg.categories.getImages.My second question is therefore: would it be possible to also get the 'rating_score' of images with the method
pwg.categories.getImages?I hope this clarifies a bit things. There is no need to modify
pwg.images.getInfoif the above questions can be answered ;-)Am I right that at the end the idea to modify pwg.images.getInfo to have parameter 'image_id' as a list was cancelled?
It's a pitty if so. May be I missed something in Piwigo Web API, but I often need to get the list of images (sometimes from different categories) to embed them in the external to Piwigo web pages of the web site (Piwigo is a part of it).
For the moment the only way I found is to get images one by one via pwg.images.getInfo. So, I have dozens of requests instead of having only one if 'image_id' would be a list of ids.
This issue is not closed and I believe that we all agree with you that we need a method to collect the parameters of a list of images. But which ones...
The method
pwg.categories.getImagesreturns: id, categories, name, comment, hit, file, date_creation, date_available, width, height, element_url, derivatives, and page_url:categories is an array containing only the cat_id of the fetched category. So it does not allow to know whether images belong to other albums. The iOS app therefore calls several times
pwg.images.getInfosto determine what to do when the user wants to delete, remove from album, move or copy a selection of images to another album.The favorites can be identified after calling
pwg.users.favorites.getListbut the rating_score can only be retrieved from a series of calls topwg.images.getInfos(to my knowledge).The method
pwg.images.getInforeturns: author, level, tags, added_by, rating_score, rates, representative_ext, filesize, md5sum, date_metadata_update, lastmodified, rotation, latitude, longitude, comments, comments_paging, and coi.The new method which we may call
pwg.images.getListInfosshould provide the complete list of cat_ids each image belongs to and the rating_score for the reasons given above. I would also add the GPS coordinates so that we can easily present a map showing where a selection of images was taken. What else? Which other parameters should be returned?To my opinion, the creation of
pwg.images.getListInfosimplies the creation ofpwg.images.setListInfos. What are your thoughts?I do not know how does it look from Piwigo developers' side, but I think that it will be better do not change
pwg.images.getInfobehaviour and parameters' list to keep backward compatibility.So, introducing
pwg.images.getListInfosis a good idea for me. I need at list the following parameters to be returned by this proposed method: author, date_metadata_update, page_url, comments, derivatives, cat_ids.For my personal use rating_score, latitude, longitude are not strictly needed, but I understand that they could be useful. And as most of the returned parameters could be the optional ones that should not be a problem, I hope.
As for creation of the companion method
pwg.images.setListInfosI'm not sure. Lets say that I do not have an opinion on this subject yet :)@EddyLB
The list of category ids returned by
pwg.images.getInfois filtered by permission. You can't rely on it to know if the image belongs to another album. What's the status on this?(I see on Piwigo.com a client who performs thousands of
pwg.images.getInfoeach day so I wonder how we could do better with a list image ids...Hi @plegall
Up to the version 3.2.5 available today on the App Store, the iOS app calls
pwg.images.getInfo:before editing the parameters of a single image (
title,author,creation_date,tags,privacy,comment) if an incomplete set of data is in cache for that image. The modified parameters are saved withpwg.images.setInfo.for copying one or a selection of images to an album. It calls the method a number of times which depends whether on image data in cache. If, for example, the selection of N images belongs to a freshly loaded album, it calls the method N times to know to which albums each image belongs to (for that user of course). Then it calls
pwg.images.setInfoN times with an updatedcategoriesvalue.for moving one or a selection of images to an album. It does a similar job. The difference resides in the value of the
categoriesparameter.for deleting one or a selection of images from an album. In that case, once all the image data is known, the app can determine which images should be removed (up to N calls of
pwg.images.setInfo) and which one should be deleted withpwg.images.delete(a single call for a set ofimage_ids).for copying a set of images to an album instead of uploading them, i.e. when the user requested an upload of an image already uploaded (same technique as for copying).
for finishing the upload of an image with the old method
pwg.images.uploadwhich has a bug preventing the naming of the image. This is now rare becausepwg.images.uploadAsyncexists for a several years.What is not implemented yet is a menu allowing to switch to one of the albums an image belongs to. This functionality is highly demanded, especially by those using the search bar. It will be available soon.
Another thing which is not implemented is a "true" Discover / Best rated album because
rating_scoreis not provided bypwg.categories.getImages. To display that album correctly, the app should systematically callpwg.images.getInfofor all the images for which it has an incomplete set of data.The same applies to comments (less demanded).
I am actually preparing a new version 3.3 which will reduce the number of calls to
pwg.images.getInfo(and speed up some actions) by exploitingpwg.images.setCategory(you can test it from TestFlight). A selection of images will be:associate)associateanddissociate)pwg.images.setCategory.Of course, for all actions, the app does the job to associate/dissociate images to albums internally to keep the cache up to date because
pwg.images.setCategorydoes not return the album data concerned by the requested action (same issue as for a few other methods).To come back to
pwg.images.getInfo, we need an efficient solution for retrieving thecat_idsof a selection of images, but alsorates,comment_post,comments, as the Piwigo would do for the user having opening the session. Why not for example to createpwg.images.getCategories,pwg.images.getRatingScoreorpwg.images.getRates, andpwg.images.getComments?Of course, it would also be great to find a solution for changing the parameters of a set of images because
pwg.images.setInfoonly applies to a single image.I hope this answers your question.
PS: In the cache, each server contains users, tags and images (image files and properties are shared by users, same for tags). To apply access rights, each album belongs to a single user and contains images. Locations, i.e. place names corresponding to GPS coordinates, are shared by all servers. As for upload requests, they belong to one user and are associated to tags.