Commit cfef4e34 authored by payno's avatar payno

[orange contrib] fix the saveimage

parent d6e79d74
......@@ -31,8 +31,9 @@ __date__ = "10/10/2018"
import os
from Orange.widgets.widget import OWWidget
from Orange.canvas.registry.description import InputSignal
from silx.gui.utils.image import convertArrayToQImage
from id06workflow.gui.settings import DEFAULT_COLORMAP
from id06workflow.core.types import _Image
from silx.gui.plot import Plot2D
import logging
_logger = logging.getLogger(__file__)
......@@ -70,10 +71,18 @@ class SaveImageOW(OWWidget):
if output is None:
_logger.warning("No environment variable define under "
"'WORKFLOW_OUTPUT'")
output = '.'
output = os.getcwd()
_logger.info('save image to %s' % output)
try:
qimage = convertArrayToQImage(image.img)
qimage.save(os.path.join(output, image.name), 'PNG')
# TODO: fix me, do not use the creation of Plot to save the image
# but a qimage ?
_name = image.name
if _name.lower().endswith('.png') is False:
_name = _name + '.png'
plot = Plot2D()
plot.setDefaultColormap(DEFAULT_COLORMAP)
plot.addImage(image.img)
plot.replot()
plot.saveGraph(filename=os.path.join(output, _name), fileFormat='png')
except Exception as e:
_logger.error(e)
......@@ -110,7 +110,7 @@ class TestTrueData(OrangeWorflowTest):
if self._previous_workflow_output is not None:
os.environ['WORKFLOW_OUTPUT'] = self._previous_workflow_output
shutil.rmtree(self._screenshot_output)
# shutil.rmtree(self._screenshot_output)
OrangeWorflowTest.tearDown(self)
def createDataset(self):
......@@ -188,18 +188,20 @@ class TestTrueData(OrangeWorflowTest):
self.assertTrue(self._shiftCorrectionWidget._editedExperiment is not None)
self._shiftCorrectionWidget.setShift(dx=0.0, dy=0.0, dz=0.0)
self._shiftCorrectionWidget.validate()
self._shiftCorrectionWidget.hide()
self._moveToNextStep()
# screenshot saving
# make sur all screenshots are processed
for i in range(9):
self._moveToNextStep()
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'intensity.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_mean.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_variance.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_sckewness.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_skewness.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_diffry_kurtosis.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_mean.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_variance.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_sckewness.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_skewness.png')))
self.assertTrue(os.path.exists(os.path.join(self._screenshot_output, 'positioner_obpitch_kurtosis.png')))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment