<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear all,<div class=""><br class=""></div><div class="">We requested in a meeting some time ago in a meeting a new functionality in the render_image_region on the web gateway of omero web.</div><div class=""><br class=""></div><div class="">Concretely we want to have the possibility to select the quality of the jpeg sent by the server. This is the code we currently added to achieve that:</div><div class=""><br class=""></div><div class="">On web gateway <em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">openmicroscopy/components/<span data-mce-style="line-height: 1.4285715;" style="line-height: 1.4285715;" class="">tools/OmeroWeb/omeroweb/webgateway/urls.py</span></em> file:</div><div class=""><br class=""></div><div class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">render_image_region_quality = ( r'^render_image_region_quality/(?P<iid>[^/]+)/(?P<z>[^/]+)/(?P<t>[^/]+)/(?P<q>[^/]+)/$',</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">                                                     'webgateway.views.render_image_region_quality')</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">"""</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">Returns a jpeg of the OMERO image, rendering only a region specified in query string as</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">region=x,y,width,height. E.g. region=0,512,256,256. If the image is much bigger than the</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">indicated baseline size, it is resized with Pillow. See L{views.render_image_region_quality}. </em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">Rendering settings can be specified in the request parameters.</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">Params in render_image/<iid>/<z>/<t>/</em><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><q>/</em><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""> are:</em></div><div class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">- iid: Image ID</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">- z: Z index</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">- t: T index</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class="">- q: JPEG quality of the returned image</em><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><em class=""><font color="#333333" face="Arial, sans-serif" class=""><span style="font-size: 14px; line-height: 20px;" class="">“”"</span></font></em></div><div class=""><em class=""><font color="#333333" face="Arial, sans-serif" class=""><span style="font-size: 14px; line-height: 20px;" class=""><br class=""></span></font></em></div><div class=""><font color="#333333" face="Arial, sans-serif" class=""><span style="font-size: 14px; line-height: 20px;" class="">On web gateway </span></font><font color="#333333" face="Arial, sans-serif" class=""><span style="font-size: 14px; line-height: 20px;" class=""><i class="">openmicroscopy/components/tools/OmeroWeb/omeroweb/webgateway/views.py </i>file (notice the small differences with the original render_image_region call, we add the quality in the ctx parameter of the web gateway_cache and the value of </span></font><b class=""><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">float(q) /</span><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""> </span></b><span data-mce-style="color: #941100;" style="font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><b class="">100.0</b><font color="#941100" class=""> </font></span><font color="#333333" face="Arial, sans-serif" class=""><span style="font-size: 14px; line-height: 20px;" class="">in the compression parameter of the </span></font><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><b class="">renderJpegRegion</b> function</span><font color="#333333" face="Arial, sans-serif" class=""><span style="font-size: 14px; line-height: 20px;" class="">):</span></font></div><div class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><br class=""></em></div><div class=""><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">@login_required<span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">()</span></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">def</span> render_image_region_quality(request, iid, z, t, q, conn=<span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span>, **kwargs):</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    <span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">"""</span></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    Returns a jpeg of the OMERO image, rendering only a region specified in query string as</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    region=x,y,width,height and resizing it. E.g. region=0,512,256,256</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    Rendering settings can be specified in the request parameters.</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @param request:     http request</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @param iid:         image ID</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @param z:           Z index</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @param t:           T index</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @param q:           Jpeg compression quality</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @param conn:        L{omero.gateway.BlitzGateway} connection</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    @return:            http response wrapping jpeg</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    """</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    server_id = request.session[<span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">'connector'</span>].server_id</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">    </span># if the region=x,y,w,h is not parsed correctly to give 4 ints then we simply provide whole image plane.</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">    </span># alternatively, could return a 404?</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">    </span>#if h == None:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">    </span>#    return render_image (request, iid, z, t, server_id=None, _conn=None, **kwargs)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    pi = _get_prepared_image(request, iid, server_id=server_id, conn=conn)</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">if</span> pi <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">is</span> <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">raise</span> Http404</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    img, compress_quality = pi</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    tile = request.REQUEST.get(<span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">'tile'</span>, <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span>)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    region = request.REQUEST.get(<span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">'region'</span>, <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span>)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    level = <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span></p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">if</span> tile:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">try</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            img._prepareRenderingEngine()</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            w, h = img._re.getTileSize()</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            levels = img._re.getResolutionLevels() - <span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">1</span></p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            zxyt = tile.split(<span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">","</span>)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">            </span>#w = int(zxyt[3])</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">            </span>#h = int(zxyt[4])</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            level = levels-int(zxyt[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">0</span>])</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            x = int(zxyt[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">1</span>])*w</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            y = int(zxyt[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">2</span>])*h</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">except</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">            logger.debug(</span>"render_image_region_quality: tile=%s"<span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class=""> % tile)</span></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            logger.debug(traceback.format_exc())</p><div style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            <br class="webkit-block-placeholder"></div><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">elif</span> region:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">try</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            xywh = region.split(<span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">","</span>)</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            x = int(xywh[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">0</span>])</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            y = int(xywh[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">1</span>])</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            w = int(xywh[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">2</span>])</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            h = int(xywh[<span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">3</span>])</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">except</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">            logger.debug(</span>"render_image_region_quality: region=%s"<span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class=""> % region)</span></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            logger.debug(traceback.format_exc())</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><span data-mce-style="color: #000000;" style="color: rgb(0, 0, 0);" class="">    </span># region details and quality in request are used as key for caching.</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    jpeg_data = webgateway_cache.getImage(request, server_id, img, z, t, ctx=q)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    jpeg_quality = float(q) / <span data-mce-style="color: #941100;" style="color: rgb(148, 17, 0);" class="">100.0</span></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">if</span> jpeg_data <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">is</span> <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">"""</span></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        jpeg_data_orig = img.renderJpegRegion(z,t,x,y,w,h,level=level, compression=jpeg_quality)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        pillow_img = Image.open(StringIO(jpeg_data_orig))</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        pillow_img = pillow_img.convert(mode="L")</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        rv = StringIO()</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        pillow_img.save(rv, 'jpeg', quality=int(10))</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        jpeg_data = rv.getvalue()</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        """</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        jpeg_data = img.renderJpegRegion(z,t,x,y,w,h,level=level, compression=jpeg_quality)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">if</span> jpeg_data <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">is</span> <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">None</span>:</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">            <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">raise</span> Http404</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">        webgateway_cache.setImage(request, server_id, img, z, t, jpeg_data, ctx=q)</p><p style="margin: 10px 0px 0px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class=""><br class=""></p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    rsp = HttpResponse(jpeg_data, content_type=<span data-mce-style="color: #00b400;" style="color: rgb(0, 180, 0);" class="">'image/jpeg'</span>)</p><p style="margin: 10px 0px 0px 30px; color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; background-color: rgb(255, 255, 255);" class="">    <span data-mce-style="color: #0433ff;" style="color: rgb(4, 51, 255);" class="">return</span> rsp</p></div><div class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><br class=""></em></div><div class=""><em style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;" class=""><br class=""></em></div></body></html>