Cytomine-ULiege / Cytomine-java-client

Client to communicate with Cytomine API in Java. Our fork includes R&D experimental features. See @cytomine for official releases.
Apache License 2.0
1 stars 1 forks source link

How can we make a request to the image server now ? #5

Open vannary opened 4 years ago

vannary commented 4 years ago

Here is our previous command: https://research.cytomine.be/api/abstractimage/10828059/imageservers.json

The code error is 403.

urubens commented 4 years ago

Hi, If you have a 403 error, it means you don't have rights to access the resource. Are you sure your are authenticated in your browser when requesting this URL ?

Anyway, this service is now deprecated. With the last Cytomine-ULiege version, an Image Instance has a collection of slices (SliceInstance) so that an image can hold several C,Z,T planes. In the case of a regular 2D image, the collection has only one item (0,0,0) . The slice instance has the attributes:

These 2 attributes help you to get what was returned by the now deprecated imageservers.json request:

 imageServer = ${slice.imageServerUrl}/slice/tile?zoomify=${slice.path}

To get these attributes with the Java Client you have to use at least the v2.2.0 release of this repo. The result can be achieved like this:

int image_id = 123
Collection<SliceInstance> c = new Collection<>(SliceInstance.class, 0,0);
        c.addFilter("imageinstance", String.valueOf(image_id));
        c.fetch();

        for (int i = 0; i < c.size(); i++) {
            System.out.println(c.get(i).getStr("imageServerUrl"));
            System.out.println(c.get(i).getStr("path"));
            System.out.println(c.get(i).getStr("imageServerUrl") + "/slice/tile?zoomify=" + c.get(i).getStr("path"));
        }
vannary commented 4 years ago

We get the ImageServer, thanks.

But now, how can we download the picture. ? previoulys downloadPictureAsBufferedImage

On Tue, Mar 3, 2020 at 7:08 PM Ulysse Rubens notifications@github.com wrote:

Hi, If you have a 403 error, it means you don't have rights to access the resource. Are you sure your are authenticated in your browser when requesting this URL ?

Anyway, this service is now deprecated. With the last Cytomine-ULiege version, an Image Instance has a collection of slices (SliceInstance) so that an image can hold several C,Z,T planes. In the case of a regular 2D image, the collection has only one item (0,0,0) . The slice instance has the attributes:

  • imageServerUrl
  • path

These 2 attributes help you to get what was returned by the now deprecated imageservers.json request:

imageServer = ${slice.imageServerUrl}/slice/tile?zoomify=${slice.path}

To get these attributes with the Java Client you have to use at least the v2.2.0 release of this repo. The result can be achieved like this:

int image_id = 123Collection c = new Collection<>(SliceInstance.class, 0,0); c.addFilter("imageinstance", String.valueOf(image_id)); c.fetch();

    for (int i = 0; i < c.size(); i++) {
        System.out.println(c.get(i).getStr("imageServerUrl"));
        System.out.println(c.get(i).getStr("path"));
        System.out.println(c.get(i).getStr("imageServerUrl") + "/slice/tile?zoomify=" + c.get(i).getStr("path"));
    }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Cytomine-ULiege/Cytomine-java-client/issues/5?email_source=notifications&email_token=AAG3FEV6GTMW46TAGMDR23TRFVBQDA5CNFSM4LAHKF6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENURHAQ#issuecomment-594088834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG3FEROQB5A2UY6YQHLXWLRFVBQDANCNFSM4LAHKF6A .

-- Vannary Meas-Yedid, PhD Institut Pasteur Unité d'Analyse d'Images Biologiques CNRS UMR 3691 25, rue du docteur Roux 75724 Paris Cedex 15 France

Tél: +33 (0)1 40 61 39 74 Fax: +33 (0)1 40 61 33 30

urubens commented 4 years ago

https://github.com/Cytomine-ULiege/Cytomine-java-client/blob/34d8ccb49473627d0dd79a612308f61f12c7e90b/src/main/java/be/cytomine/client/CytomineConnection.java#L284 should do the trick