Search in sources :

Example 56 with FunctionException

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

the class ErodeFilter 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("Threshold"))) != null)
        setThreshold(ImageFilterUtil.toIntValue(o, "Threshold"));
    if ((o = parameters.removeEL(KeyImpl.init("Iterations"))) != null)
        setIterations(ImageFilterUtil.toIntValue(o, "Iterations"));
    if ((o = parameters.removeEL(KeyImpl.init("Colormap"))) != null)
        setColormap(ImageFilterUtil.toColormap(o, "Colormap"));
    if ((o = parameters.removeEL(KeyImpl.init("NewColor"))) != null)
        setNewColor(ImageFilterUtil.toColorRGB(o, "NewColor"));
    // 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 [Threshold, Iterations, Colormap, NewColor, BlackFunction]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 57 with FunctionException

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

the class ExposureFilter 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("Exposure"))) != null)
        setExposure(ImageFilterUtil.toFloatValue(o, "Exposure"));
    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 [Exposure, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 58 with FunctionException

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

the class FBMFilter 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("Colormap"))) != null)
        setColormap(ImageFilterUtil.toColormap(o, "Colormap"));
    if ((o = parameters.removeEL(KeyImpl.init("Amount"))) != null)
        setAmount(ImageFilterUtil.toFloatValue(o, "Amount"));
    if ((o = parameters.removeEL(KeyImpl.init("Stretch"))) != null)
        setStretch(ImageFilterUtil.toFloatValue(o, "Stretch"));
    if ((o = parameters.removeEL(KeyImpl.init("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("BasisType"))) != null)
        setBasisType(ImageFilterUtil.toIntValue(o, "BasisType"));
    if ((o = parameters.removeEL(KeyImpl.init("Operation"))) != null)
        setOperation(ImageFilterUtil.toIntValue(o, "Operation"));
    if ((o = parameters.removeEL(KeyImpl.init("Octaves"))) != null)
        setOctaves(ImageFilterUtil.toFloatValue(o, "Octaves"));
    if ((o = parameters.removeEL(KeyImpl.init("H"))) != null)
        setH(ImageFilterUtil.toFloatValue(o, "H"));
    if ((o = parameters.removeEL(KeyImpl.init("Lacunarity"))) != null)
        setLacunarity(ImageFilterUtil.toFloatValue(o, "Lacunarity"));
    if ((o = parameters.removeEL(KeyImpl.init("Gain"))) != null)
        setGain(ImageFilterUtil.toFloatValue(o, "Gain"));
    if ((o = parameters.removeEL(KeyImpl.init("Bias"))) != null)
        setBias(ImageFilterUtil.toFloatValue(o, "Bias"));
    if ((o = parameters.removeEL(KeyImpl.init("Basis"))) != null)
        setBasis(ImageFilterUtil.toFunction2D(o, "Basis"));
    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 [Colormap, Amount, Stretch, Angle, BasisType, Operation, Octaves, H, Lacunarity, Gain, Bias, Basis, Scale, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 59 with FunctionException

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

the class FadeFilter 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("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("Sides"))) != null)
        setSides(ImageFilterUtil.toIntValue(o, "Sides"));
    if ((o = parameters.removeEL(KeyImpl.init("FadeStart"))) != null)
        setFadeStart(ImageFilterUtil.toFloatValue(o, "FadeStart"));
    if ((o = parameters.removeEL(KeyImpl.init("FadeWidth"))) != null)
        setFadeWidth(ImageFilterUtil.toFloatValue(o, "FadeWidth"));
    if ((o = parameters.removeEL(KeyImpl.init("Invert"))) != null)
        setInvert(ImageFilterUtil.toBooleanValue(o, "Invert"));
    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 [Angle, Sides, FadeStart, FadeWidth, Invert, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 60 with FunctionException

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

the class FeedbackFilter 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("Iterations"))) != null)
        setIterations(ImageFilterUtil.toIntValue(o, "Iterations"));
    if ((o = parameters.removeEL(KeyImpl.init("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("CentreX"))) != null)
        setCentreX(ImageFilterUtil.toFloatValue(o, "CentreX"));
    if ((o = parameters.removeEL(KeyImpl.init("CentreY"))) != null)
        setCentreY(ImageFilterUtil.toFloatValue(o, "CentreY"));
    // if((o=parameters.removeEL(KeyImpl.init("Centre")))!=null)setCentre(ImageFilterUtil.toPoint2D(o,"Centre"));
    if ((o = parameters.removeEL(KeyImpl.init("Distance"))) != null)
        setDistance(ImageFilterUtil.toFloatValue(o, "Distance"));
    if ((o = parameters.removeEL(KeyImpl.init("Rotation"))) != null)
        setRotation(ImageFilterUtil.toFloatValue(o, "Rotation"));
    if ((o = parameters.removeEL(KeyImpl.init("Zoom"))) != null)
        setZoom(ImageFilterUtil.toFloatValue(o, "Zoom"));
    if ((o = parameters.removeEL(KeyImpl.init("StartAlpha"))) != null)
        setStartAlpha(ImageFilterUtil.toFloatValue(o, "StartAlpha"));
    if ((o = parameters.removeEL(KeyImpl.init("EndAlpha"))) != null)
        setEndAlpha(ImageFilterUtil.toFloatValue(o, "EndAlpha"));
    // 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 [Iterations, Angle, CentreX, CentreY, Centre, Distance, Rotation, Zoom, StartAlpha, EndAlpha]");
    }
    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