Search in sources :

Example 31 with FunctionException

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

the class ShapeFilter 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("UseAlpha"))) != null)
        setUseAlpha(ImageFilterUtil.toBooleanValue(o, "UseAlpha"));
    if ((o = parameters.removeEL(KeyImpl.init("Colormap"))) != null)
        setColormap(ImageFilterUtil.toColormap(o, "Colormap"));
    if ((o = parameters.removeEL(KeyImpl.init("Invert"))) != null)
        setInvert(ImageFilterUtil.toBooleanValue(o, "Invert"));
    if ((o = parameters.removeEL(KeyImpl.init("Factor"))) != null)
        setFactor(ImageFilterUtil.toFloatValue(o, "Factor"));
    if ((o = parameters.removeEL(KeyImpl.init("Merge"))) != null)
        setMerge(ImageFilterUtil.toBooleanValue(o, "Merge"));
    if ((o = parameters.removeEL(KeyImpl.init("Type"))) != null)
        setType(ImageFilterUtil.toIntValue(o, "Type"));
    // 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 [UseAlpha, Colormap, Invert, Factor, Merge, Type]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 32 with FunctionException

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

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

Example 33 with FunctionException

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

the class ShatterFilter 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("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("Transition"))) != null)
        setTransition(ImageFilterUtil.toFloatValue(o, "Transition"));
    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"));
    if ((o = parameters.removeEL(KeyImpl.init("Tile"))) != null)
        setTile(ImageFilterUtil.toIntValue(o, "Tile"));
    // 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, CentreX, CentreY, Centre, Transition, Distance, Rotation, Zoom, StartAlpha, EndAlpha, Tile]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 34 with FunctionException

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

the class ShineFilter 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("Brightness"))) != null)
        setBrightness(ImageFilterUtil.toFloatValue(o, "Brightness"));
    if ((o = parameters.removeEL(KeyImpl.init("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("Softness"))) != null)
        setSoftness(ImageFilterUtil.toFloatValue(o, "Softness"));
    if ((o = parameters.removeEL(KeyImpl.init("Distance"))) != null)
        setDistance(ImageFilterUtil.toFloatValue(o, "Distance"));
    if ((o = parameters.removeEL(KeyImpl.init("ShadowOnly"))) != null)
        setShadowOnly(ImageFilterUtil.toBooleanValue(o, "ShadowOnly"));
    if ((o = parameters.removeEL(KeyImpl.init("Bevel"))) != null)
        setBevel(ImageFilterUtil.toFloatValue(o, "Bevel"));
    if ((o = parameters.removeEL(KeyImpl.init("ShineColor"))) != null)
        setShineColor(ImageFilterUtil.toColorRGB(o, "ShineColor"));
    // 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, Brightness, Angle, Softness, Distance, ShadowOnly, Bevel, ShineColor]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 35 with FunctionException

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

the class SmartBlurFilter 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("HRadius"))) != null)
        setHRadius(ImageFilterUtil.toIntValue(o, "HRadius"));
    if ((o = parameters.removeEL(KeyImpl.init("VRadius"))) != null)
        setVRadius(ImageFilterUtil.toIntValue(o, "VRadius"));
    if ((o = parameters.removeEL(KeyImpl.init("Radius"))) != null)
        setRadius(ImageFilterUtil.toIntValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("Threshold"))) != null)
        setThreshold(ImageFilterUtil.toIntValue(o, "Threshold"));
    // 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 [HRadius, VRadius, Radius, Threshold]");
    }
    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