Zenphoto REST api - Integration with other software

Hey guys i have made an app for Piwigo gallery that help users to post photos from gallery into other software like Worpress or various forums types. http://piwigo.org/ext/extension_view.php?eid=835

I want to make something similar for Zenphoto.

But i have some problems

1) Current api seem unsupported by it's original autor. Both Piwigo and Menalto Gallery 3 have api that are officially supported and documented. Please support your Zenphoto REST api officially. They are some bugs some incomplete stuff, and there is no documentation for it.

2) Is possible to make the derivative file names not contain the size in pixels? Because having that number in the filename easily will broke any links to the thumbnail and websize in the future.

For example if a software like mine generate a bbcode like this for a forum software:

`[url=http://site.com/cache/someuser/filename_595.jpg][img]http://site.com/cache/someuser/filename_150_cw150_ch150_thumb.jpg[/img][/url]`

If the user change the size of the thumbnails or websize then the original link embeded in other software can be broken.
Piwigo dont have that size included in the filenames. They use something like this
filename-sq.jpg (square thumbnail)
filename-th.jpg (small thumbnail)
filename-me.jpg (websize thumbnail)
filename.jpg (original filename)
When user change the size option in his options panel he is not broking the past links.

Comments

  • acrylian Administrator, Developer
    1) There is no offical REST API for Zenphoto. There is a 3rd party plugin: https://github.com/deanmoses/tacocat-gallery-zenphoto-rest-api
    I have plans to create an more complete official (read only) REST API following that principle for the next big release. That release sadly will take some time as time is sadly an issue.

    For now you would have to use RSS. There is an probably rather inconvenient externalRSS plugin you could use for now.

    2) No, those file names are the names of the cached files and they tell Zenphoto that it does not need to process this specific sizes again. That cannot be changed.
    Piwigo and WP do use a fixed set of image sizes they pregenerated. But Zenphoto does not do this and leaves the freedom to use any size in any number to theme and plugins. So there are no fixed file names possible to link to. To change the size without using Zenphoto itself you woul have to call the image processor (see zp-core/i.php): But you really don't want to allow that to everyone from the outside as that surely can overload your server.
  • then ...

    1) nice to hear that. i already builded my zenphoto2img app one week ago based on "tacocat-gallery-zenphoto-rest-api", but this app is more primitive compared with my piwigo app. because with the current zenphoto REST api you get less info about images and albums. also is very hard to build an album tree because you cannot get that from a single api request, so i'm building only the main albums first making one request, then using ajax i'm building the subalbums for the selected album.

    also got the same bug like this guy reported 9 months ago and the autor didn't fix the problem
    https://github.com/deanmoses/tacocat-gallery-zenphoto-rest-api/issues/4

    2) then this is bad if the filename must contain the image size in pixels. this will make zenphoto links very brokeable when integrating zenphoto in any other type of software.
  • acrylian Administrator, Developer
    1) Sorry, cannot say much to that as I didn't actually use that plugin. The plugin I have in mind will mirror the standard front end usage more or less.

    2) Well, it is how Zenphoto works and this will not be changed. Those cached images are not fixed, the cache may be deleted so it is not recommended to link to that directly with fixed links. Instead use the image processor if you are not sure. That will either create the cache image or serve existing ones. Which actually the api would do before returning anything.
  • 2) by image processor ... you mean "i.php" ?

    can you give an example how "i.php" query parameter would look like to be equivalent with this kind of links?

    websize:
    http://site.com/cache/someuser/filename_595.jpg = http://site.com/i.php?...

    thumb:
    http://site.com/cache/someuser/filename_150_cw150_ch150_thumb.jpg = http://site.com/i.php?...
  • acrylian Administrator, Developer
    Yes, that's the image processor. Best you see the file's docblock ifself for the available parameters.
  • Hi, I'm the guy that wrote that unsupported REST API and didn't fix anything for a year. Believe me, I'd also love it if there were an official, supported API!

    But in the meantime I fixed up mine.

    1) The bugs people filed issues for are fixed.
    2) You get the whole tree of albums all the way down; it doesn't stop at one level.
    3) It still doesn't get as many fields as you want, eliz82. If you have specific fields I can add them. Anybody know if there's a way to iterate over all fields?

    It's at a new location:
    https://github.com/deanmoses/zenphoto-json-rest-api
  • acrylian Administrator, Developer
    Entry on our extensions section has already been updated!
  • @deanmoses
    The "deep" parameter seems nice, allowing me to fix one of the problems.
    I will take a look at the api new version when I will have some free time.

    @acrylian
    By "file's docblock" you mean looking at the "i.php" source code, or there is some sort of documentation for zenphoto?
  • acrylian Administrator, Developer
    All or the majority of functions etc are documented by in file comments (called docblocks for their formatting to match doc generators). There is also a generate documentation (see the user guide) but that is generated from exactly those comments.
  • Tobias Member

    I know this topic is quite old, but wanted to add anyway in case someone has the same requirements.

    2) Is possible to make the derivative file names not contain the size in pixels? Because having that number in the filename easily will broke any links to the thumbnail and websize in the future.

    For example if a software like mine generate a bbcode like this for a forum software:

    [url=http://site.com/cache/someuser/filename_595.jpg][img]http://site.com/cache/someuser/filename_150_cw150_ch150_thumb.jpg[/img][/url]

    If the user change the size of the thumbnails or websize then the original link embeded in other software can be broken.
    Piwigo dont have that size included in the filenames. They use something like this
    filename-sq.jpg (square thumbnail)
    filename-th.jpg (small thumbnail)
    filename-me.jpg (websize thumbnail)
    filename.jpg (original filename)
    When user change the size option in his options panel he is not broking the past links.

    You could use a .htaccess rewrite rule for those pre-defined image sizes. Something like this (untested):

    RewriteRule ^(.*)(-sq\.jpg)$ $1_150_cw150_ch150_thumb.jpg
    

    This should match all file requests ending in -sq.jpg and redirect those requests to the same filename but ending in _150_cw150_ch150.jpg instead.

    Once you decide to go to 175 px sized thumbnails (for example) you just change the rewrite rule and you're done (caching aside as noted above).

  • acrylian Administrator, Developer

    You should really not rely on someething like this as just a theme of plugin may not use that size. The cached file names contain the size parameters for a reason. Zenphoto does not have fixed sizes like Piwigo or other CMS have, themes and plugins can use whatever they want whenever they want.

Sign In or Register to comment.