001 package railo.runtime.functions.image; 002 003 import java.io.IOException; 004 005 import railo.commons.io.res.util.ResourceUtil; 006 import railo.runtime.PageContext; 007 import railo.runtime.exp.PageException; 008 import railo.runtime.img.Image; 009 import railo.runtime.op.Caster; 010 011 public class ImageWriteBase64 { 012 013 public static String call(PageContext pc, Object name, String destination, String format) throws PageException { 014 return call(pc, name, destination, format,false); 015 } 016 017 public static String call(PageContext pc, Object name, String destination, String format, boolean inHTMLFormat) throws PageException { 018 if(name instanceof String) 019 name=pc.getVariable(Caster.toString(name)); 020 Image image=Image.toImage(name); 021 try { 022 return image.writeBase64(ResourceUtil.toResourceNotExisting(pc, destination), format, inHTMLFormat); 023 } catch (IOException e) { 024 throw Caster.toPageException(e); 025 } 026 027 } 028 }