[ome-devel] OmeroWeb API support for thumbnails with rendering parameters possible?

José Salavert Torres josator at ebi.ac.uk
Fri Dec 12 12:02:39 GMT 2014


Dear Omero Developers,

I am trying to use OMERO Web to visualise image thumbnails of any slice (z,t) and supporting rendering parameters as well, concretely those related with the contrast (?c=1|-3000,3000).
So far I managed to add a new django web service to OMERO Web.
This new view is able to render these down-sampled versions of the images at any Z and T (this option was already implemented in OMERO Py omero.gateway package in the getThumbnail() function, but not accessible from OMERO Web).
The new view is also capable of using the webgateway_cache to store the files using setImage() and getImage() with a special ctx string that is added to the image id.

However, for the EMPIAR 3D viewer I need also to set the contrast of the down-sampled images, so I would need support for (?c=1|-3000,3000) parameters to adjust the contrast of the thumbnail.

If you could provide some feedback on OMERO PY omero.gateway package I would appreciate it. I am digging in the getThumbnail(), _prepareTB() and renderJpeg(). I think that _prepareTB is resetting the context parameters but I am not sure about this.

So far this is the code for the new OMERO Web Call:


@login_required()
def render_slice_thumbnail (request, iid, z, t, w=None, h=None, conn=None, _defcb=None, **kwargs):
    """
    Returns an HttpResponse wrapped jpeg with the rendered thumbnail for image 'iid'

    @param request:     http request
    @param iid:         Image ID
    @param z:           Z index
    @param t:           T index
    @param w:           Thumbnail max width. 64 by default
    @param h:           Thumbnail max height
    @return:            http response containing jpeg
    """

    server_id = request.session['connector'].server_id
    direct = True
    if w is None:
        size = (64,)
    else:
        if h is None:
            size = (int(w),)
        else:
            size = (int(w), int(h))
    if size == (96,):
        direct = False
        
    pi = _get_prepared_image(request, iid, server_id=server_id, conn=conn)
    if pi is None:
        raise Http404
    img, compress_quality = pi
    
    rdefId = request.REQUEST.get('rdefId', None)
    if rdefId is not None:
        rdefId = int(rdefId)

    jpeg_data = webgateway_cache.getImage(request, server_id, img, z, t, ctx='thumbslice' + w + 'x' + h)
    if jpeg_data is None:
        prevent_cache = False
        img = conn.getObject("Image", iid)
        if img is None:
            logger.debug("(b)Image %s not found..." % (str(iid)))
            if _defcb:
                jpeg_data = _defcb(size=size)
                prevent_cache = True
            else:
                raise Http404
        else:
            jpeg_data = img.getThumbnail(size=size, z=int(z), t=int(t), direct=direct, rdefId=rdefId)
            if jpeg_data is None:
                logger.debug("(c)Image %s not found..." % (str(iid)))
                if _defcb:
                    jpeg_data = _defcb(size=size)
                    prevent_cache = True
                else:
                    return HttpResponseServerError('Failed to render thumbnail')
            else:
                prevent_cache = img._thumbInProgress
        if not prevent_cache:
            webgateway_cache.setImage(request, server_id, img, z, t, jpeg_data, ctx='thumbslice' + w + 'x' + h)
    else:
        pass
    rsp = HttpResponse(jpeg_data, content_type='image/jpeg')
    return rsp


The parameters in the context (?c=1|-3000,3000) are set using the _get_prepared_image function() (which is a function used in render_image call).
However the image is not modified.

Some questions:

1 - How can I compile the OmeroWeb package and run it. I have tryed compiling components/tools/omeroWEB only, but then the command omero web start does not load the updated version. Also the default option for “components/tools/OmeroWeb/build.xml 

2 - In img.getThumbnail(size=size, z=int(z), t=int(t), direct=direct, rdefId=rdefId) rdefId is not used inside the function, the same for the _r in _prepareTB().

3- Where are the logs of the "omero web start” command stored? I would like to check if _prepareTB() is reseting the grayscale parameters in the context. Also, how can I manually kill the web server if it hangs?

4- I am lost when the code reaches OmeroPy/build/lib/omero_api_ThumbnailSotre_ice.py remote procedure calls  (def getThumbnailForSectionDirect(self, theZ, theT, sizeX, sizeY, _ctx=None)). I would like to check also if the context parameters are read by the generate thumbnail function in the server side.

Thank you in advance,
José Salavert Torres
EMBL-EBI, pdbe/emdb/empiar3d

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20141212/c00d5702/attachment.html>


More information about the ome-devel mailing list