Search in sources :

Example 86 with FunctionException

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

the class ImageGetEXIFTag method call.

public static Object call(PageContext pc, Object name, String tagName) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    // ImageGetEXIFMetadata.getData(img);
    Struct data = img.info();
    Object value = data.get(tagName, null);
    if (value == null) {
        throw new FunctionException(pc, "ImageGetEXIFTag", 2, "tagName", ExceptionUtil.similarKeyMessage(data, tagName, "tag", "tags", null, true));
    }
    return value;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image) Struct(lucee.runtime.type.Struct)

Example 87 with FunctionException

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

the class ImageResize method call.

public static String call(PageContext pc, Object name, String width, String height, String interpolation, double blurFactor) throws PageException {
    // image
    // if(name instanceof String)name=pc.getVariable(Caster.toString(name));
    Image image = Image.toImage(pc, name);
    interpolation = interpolation.toLowerCase().trim();
    if (blurFactor <= 0.0 || blurFactor > 10.0)
        throw new FunctionException(pc, "ImageResize", 5, "blurFactor", "argument blurFactor must be between 0 and 10");
    // MUST interpolation/blur
    // if(!"highestquality".equals(interpolation) || blurFactor!=1.0)throw new ExpressionException("argument interpolation and blurFactor are not supported for function ImageResize");
    image.resize(width, height, interpolation, blurFactor);
    return null;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image)

Example 88 with FunctionException

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

the class ImageSetDrawingAlpha method call.

public static String call(PageContext pc, Object name, double alpha) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    if (alpha < 0 || alpha > 1)
        throw new FunctionException(pc, "ImageSetDrawingAlpha", 2, "alpha", "alpha must be a value between 0 and 1");
    img.setAlpha((float) alpha);
    return null;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image)

Example 89 with FunctionException

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

the class ImageSetDrawingTransparency method call.

public static String call(PageContext pc, Object name, double percent) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    if (percent < 0.0 || percent > 100.0)
        throw new FunctionException(pc, "ImageSetDrawingTransparency", 2, "percent", "value must be between 0 and 100");
    img.setTranparency((float) percent);
    return null;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image)

Example 90 with FunctionException

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

the class ImageSharpen method call.

public static String call(PageContext pc, Object name, double gain) throws PageException {
    // if(name instanceof String) name=pc.getVariable(Caster.toString(name));
    Image img = Image.toImage(pc, name);
    if (gain < -1.0 || gain > 2.0)
        throw new FunctionException(pc, "ImageSharpen", 2, "gain", "value must be between 1 and 2");
    img.sharpen((float) gain);
    return null;
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Image(lucee.runtime.img.Image)

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