use of org.knime.core.node.port.image.ImagePortObject in project GenericKnimeNodes by genericworkflownodes.
the class Image2FilePortNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
ImagePortObject imageObj = (ImagePortObject) inObjects[0];
DataCell imageCellDC = imageObj.toDataCell();
if (!(imageCellDC instanceof ImageValue)) {
throw new InvalidSettingsException("Image object does not produce" + " valid image object but " + imageCellDC.getClass().getName());
}
ImageValue v = (ImageValue) imageCellDC;
ImageContent content = v.getImageContent();
// check if the extension matches our PNG assumption
checkExtension(v);
// write the file to stash
FileStoreURIPortObject outPort = writeImageFile(content, exec);
return new PortObject[] { outPort };
}
Aggregations