Exporting images
Posted: 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:
Thank you very much for your help,
The WebValley Team
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