Search in sources :

Example 21 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class PolarFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    // ImageUtil.createBufferedImage(src);
    BufferedImage dst = null;
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Type"))) != null)
        setType(ImageFilterUtil.toString(o, "Type"));
    if ((o = parameters.removeEL(KeyImpl.init("EdgeAction"))) != null)
        setEdgeAction(ImageFilterUtil.toString(o, "EdgeAction"));
    if ((o = parameters.removeEL(KeyImpl.init("Interpolation"))) != null)
        setInterpolation(ImageFilterUtil.toString(o, "Interpolation"));
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Type, EdgeAction, Interpolation]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 22 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class PosterizeFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("NumLevels"))) != null)
        setNumLevels(ImageFilterUtil.toIntValue(o, "NumLevels"));
    if ((o = parameters.removeEL(KeyImpl.init("Dimensions"))) != null) {
        int[] dim = ImageFilterUtil.toDimensions(o, "Dimensions");
        setDimensions(dim[0], dim[1]);
    }
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [NumLevels, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 23 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class QuantizeFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Serpentine"))) != null)
        setSerpentine(ImageFilterUtil.toBooleanValue(o, "Serpentine"));
    if ((o = parameters.removeEL(KeyImpl.init("NumColors"))) != null)
        setNumColors(ImageFilterUtil.toIntValue(o, "NumColors"));
    if ((o = parameters.removeEL(KeyImpl.init("Dither"))) != null)
        setDither(ImageFilterUtil.toBooleanValue(o, "Dither"));
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Serpentine, NumColors, Dither]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 24 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class RenderTextFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Font"))) != null)
        setFont(ImageFilterUtil.toFont(o, "Font"));
    if ((o = parameters.removeEL(KeyImpl.init("Transform"))) != null)
        setTransform(ImageFilterUtil.toAffineTransform(o, "Transform"));
    if ((o = parameters.removeEL(KeyImpl.init("Composite"))) != null)
        setComposite(ImageFilterUtil.toComposite(o, "Composite"));
    if ((o = parameters.removeEL(KeyImpl.init("Paint"))) != null)
        setPaint(ImageFilterUtil.toColor(o, "Paint"));
    if ((o = parameters.removeEL(KeyImpl.init("Text"))) != null)
        setText(ImageFilterUtil.toString(o, "Text"));
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Font, Transform, Composite, Paint, Text]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 25 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class RescaleFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Scale"))) != null)
        setScale(ImageFilterUtil.toFloatValue(o, "Scale"));
    if ((o = parameters.removeEL(KeyImpl.init("Dimensions"))) != null) {
        int[] dim = ImageFilterUtil.toDimensions(o, "Dimensions");
        setDimensions(dim[0], dim[1]);
    }
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Scale, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Aggregations

FunctionException (lucee.runtime.exp.FunctionException)189 BufferedImage (java.awt.image.BufferedImage)123 Image (lucee.runtime.img.Image)17 Struct (lucee.runtime.type.Struct)13 Array (lucee.runtime.type.Array)12 Resource (lucee.commons.io.res.Resource)10 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 Iterator (java.util.Iterator)6 Query (lucee.runtime.type.Query)6 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)6 Enumeration (java.util.Enumeration)5 List (java.util.List)5 ListIterator (java.util.ListIterator)5 ExecutorService (java.util.concurrent.ExecutorService)5 Future (java.util.concurrent.Future)5 Iteratorable (lucee.runtime.type.Iteratorable)5 StringListData (lucee.runtime.type.util.StringListData)5 ArrayImpl (lucee.runtime.type.ArrayImpl)4 StructImpl (lucee.runtime.type.StructImpl)4