mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Allow showing png and jpg contents as invocation outputs
This commit is contained in:
@@ -482,6 +482,8 @@ class Data(object):
|
||||
If the data cannot reasonably be displayed, just indicate this and do
|
||||
not throw an exception.
|
||||
"""
|
||||
if self.file_ext in {'png', 'jpg'}:
|
||||
return self.handle_dataset_as_image(dataset_instance)
|
||||
if self.is_binary:
|
||||
result = "*cannot display binary content*\n"
|
||||
else:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Image classes
|
||||
"""
|
||||
import base64
|
||||
import logging
|
||||
import zipfile
|
||||
|
||||
@@ -46,6 +47,13 @@ class Image(data.Data):
|
||||
"""Determine if the file is in this format"""
|
||||
return check_image_type(filename, self.image_formats)
|
||||
|
||||
def handle_dataset_as_image(self, hda):
|
||||
dataset = hda.dataset
|
||||
name = hda.name or ''
|
||||
with open(dataset.file_name, "rb") as f:
|
||||
base64_image_data = base64.b64encode(f.read()).decode("utf-8")
|
||||
return "" % (name, self.file_ext, base64_image_data)
|
||||
|
||||
|
||||
class Jpg(Image):
|
||||
edam_format = "format_3579"
|
||||
|
||||
Reference in New Issue
Block a user