Search in sources :

Example 36 with FunctionException

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

the class SparkleFilter 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("Radius"))) != null)
        setRadius(ImageFilterUtil.toIntValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("Amount"))) != null)
        setAmount(ImageFilterUtil.toIntValue(o, "Amount"));
    if ((o = parameters.removeEL(KeyImpl.init("Randomness"))) != null)
        setRandomness(ImageFilterUtil.toIntValue(o, "Randomness"));
    if ((o = parameters.removeEL(KeyImpl.init("Rays"))) != null)
        setRays(ImageFilterUtil.toIntValue(o, "Rays"));
    if ((o = parameters.removeEL(KeyImpl.init("Color"))) != null)
        setColor(ImageFilterUtil.toColorRGB(o, "Color"));
    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 [Radius, Amount, Randomness, Rays, Color, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 37 with FunctionException

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

the class StampFilter 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("Radius"))) != null)
        setRadius(ImageFilterUtil.toFloatValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("Softness"))) != null)
        setSoftness(ImageFilterUtil.toFloatValue(o, "Softness"));
    if ((o = parameters.removeEL(KeyImpl.init("White"))) != null)
        setWhite(ImageFilterUtil.toColor(o, "White"));
    if ((o = parameters.removeEL(KeyImpl.init("Black"))) != null)
        setBlack(ImageFilterUtil.toColor(o, "Black"));
    if ((o = parameters.removeEL(KeyImpl.init("Threshold"))) != null)
        setThreshold(ImageFilterUtil.toFloatValue(o, "Threshold"));
    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 [Radius, Softness, White, Black, Threshold, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 38 with FunctionException

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

the class TransitionFilter 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("Transition"))) != null)
        setTransition(ImageFilterUtil.toFloatValue(o, "Transition"));
    if ((o = parameters.removeEL(KeyImpl.init("destination"))) != null)
        setDestination(ImageFilterUtil.toBufferedImage(o, "destination"));
    // 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 [Transition]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 39 with FunctionException

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

the class UnpremultiplyFilter 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("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 [Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 40 with FunctionException

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

the class UnsharpFilter 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("Amount"))) != null)
        setAmount(ImageFilterUtil.toFloatValue(o, "Amount"));
    if ((o = parameters.removeEL(KeyImpl.init("Threshold"))) != null)
        setThreshold(ImageFilterUtil.toIntValue(o, "Threshold"));
    if ((o = parameters.removeEL(KeyImpl.init("Radius"))) != null)
        setRadius(ImageFilterUtil.toFloatValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("EdgeAction"))) != null)
        setEdgeAction(ImageFilterUtil.toString(o, "EdgeAction"));
    if ((o = parameters.removeEL(KeyImpl.init("UseAlpha"))) != null)
        setUseAlpha(ImageFilterUtil.toBooleanValue(o, "UseAlpha"));
    if ((o = parameters.removeEL(KeyImpl.init("PremultiplyAlpha"))) != null)
        setPremultiplyAlpha(ImageFilterUtil.toBooleanValue(o, "PremultiplyAlpha"));
    // 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 [Amount, Threshold, Radius, Kernel, EdgeAction, UseAlpha, PremultiplyAlpha]");
    }
    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