Search in sources :

Example 6 with ImagePortObject

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 };
}
Also used : FileStoreURIPortObject(com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ImageContent(org.knime.core.data.image.ImageContent) DataCell(org.knime.core.data.DataCell) ImagePortObject(org.knime.core.node.port.image.ImagePortObject) ImageValue(org.knime.core.data.image.ImageValue) IURIPortObject(org.knime.core.data.uri.IURIPortObject) PortObject(org.knime.core.node.port.PortObject) ImagePortObject(org.knime.core.node.port.image.ImagePortObject) FileStoreURIPortObject(com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject)

Aggregations

PortObject (org.knime.core.node.port.PortObject)6 ImagePortObject (org.knime.core.node.port.image.ImagePortObject)6 DataCell (org.knime.core.data.DataCell)4 ImageContent (org.knime.core.data.image.ImageContent)4 ImageValue (org.knime.core.data.image.ImageValue)4 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataRow (org.knime.core.data.DataRow)2 DataTableSpec (org.knime.core.data.DataTableSpec)2 PNGImageContent (org.knime.core.data.image.png.PNGImageContent)2 PNGImageValue (org.knime.core.data.image.png.PNGImageValue)2 BufferedDataTable (org.knime.core.node.BufferedDataTable)2 ImagePortObjectSpec (org.knime.core.node.port.image.ImagePortObjectSpec)2 FileStoreURIPortObject (com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject)1 Graphics2D (java.awt.Graphics2D)1 GraphicsConfiguration (java.awt.GraphicsConfiguration)1 GraphicsEnvironment (java.awt.GraphicsEnvironment)1 BufferedImage (java.awt.image.BufferedImage)1 BufferedOutputStream (java.io.BufferedOutputStream)1