We're Hiring!

Exporting images

General user discussion about using the OMERO platform to its fullest. Please ask new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Exporting images

Postby webvalley » Sat Jul 13, 2013 4:40 pm

Hello guys,
we are trying to create a python script (to run into omero) which will upload an image to a remote server via post.
The problem is that we can not figure out how to get either a PIL image or just raw binary data from an omero image.
This is the code we wrote so far:
Code: Select all
from omero.gateway import BlitzGateway
import omero.util.script_utils as scriptUtil
from omero.rtypes import *
import omero.scripts as scripts
import requests

try:
    from PIL import Image
except ImportError:
    import Image

if __name__ == "__main__":
    dataTypes = [rstring('Image')]
    client = scripts.client('TestUpload', """Testing the upload of an image to a remote server""",
                            scripts.String("Data_Type", optional=False, grouping="1",
                                           description="Choose source of images (only Image supported)",
                                           values=dataTypes, default="Image"),
                            scripts.List("IDs", optional=False, grouping="2",
                                         description="List of Image IDs to change annotations for.").ofType(rlong(0)),
                            version='0.1',
                            authors=['The WebValley Team', ""],
                            institutions=['WebValley'],
                            contact='webvalley@fbk.eu')

    try:
        # process the list of args above.
        scriptParams = {}
        for key in client.getInputKeys():
            if client.getInput(key):
                scriptParams[key] = client.getInput(key, unwrap=True)

        conn = BlitzGateway(client_obj=client)
        # updateService = conn.getUpdateService()

        images, logMessage = scriptUtil.getObjects(conn, scriptParams)

        for image in images:
            payload = {'file': image._obj}
            r = requests.post("http://192.168.205.10/post.php", files=payload)

    finally:
        client.closeSession()

Thank you very much for your help,
The WebValley Team
webvalley
 
Posts: 3
Joined: Tue Jun 12, 2012 1:20 pm

Re: Exporting images

Postby atarkowska » Mon Jul 15, 2013 10:34 am

Hi,

You have two options to do it. Either you can render thumbnail or image. Please find an examples how to do it in our training materials.

More details about BlitzGateway interface is available in the documentation.

I hope it will be helpful.

Ola
atarkowska
 
Posts: 327
Joined: Mon May 18, 2009 12:44 pm

Re: Exporting images

Postby wmoore » Thu Jul 18, 2013 10:17 pm

You could also look at the https://github.com/ome/scripts/blob/mas ... _Export.py script, which ships with OMERO and uses PIL images to save images to disk. This will probably have most of the code you need.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to User Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest