001    package railo.runtime.functions.image;
002    
003    import railo.runtime.PageContext;
004    import railo.runtime.exp.FunctionException;
005    import railo.runtime.exp.PageException;
006    import railo.runtime.img.Image;
007    import railo.runtime.op.Caster;
008    
009    public class ImageCrop {
010    
011            public static String call(PageContext pc, Object name, double x, double y, double width, double height) throws PageException {
012                    if(name instanceof String) name=pc.getVariable(Caster.toString(name));
013                    Image img = Image.toImage(name);
014                    
015                    if (width < 0)
016                        throw new FunctionException(pc,"ImageCrop",3,"width","width must contain a none negative value");
017                    if (height < 0)
018                        throw new FunctionException(pc,"ImageCrop",4,"height","width must contain a none negative value");
019                    
020                    img.crop((float)x, (float)y, (float)width, (float)height);
021                    return null;
022            }
023            
024    }