Top
Resizing Transparent PNG in ColdFusion – Dragos Cirjan
fade
735
post-template-default,single,single-post,postid-735,single-format-standard,eltd-core-1.1.1,flow child-child-ver-1.0.0,flow-ver-1.3.6,,eltd-smooth-page-transitions,ajax,eltd-blog-installed,page-template-blog-standard,eltd-header-standard,eltd-fixed-on-scroll,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-dropdown-default,wpb-js-composer js-comp-ver-5.0.1,vc_responsive

Warning: A non-numeric value encountered in /usr/src/wordpress/wp-content/themes/flow/framework/modules/title/title-functions.php on line 417

Resizing Transparent PNG in ColdFusion

Resizing Transparent PNG in ColdFusion

Hello guys,

Needed to do this for a project my team is maintaining, but I could only find the solution for ColdFusion, which looks like this:

JavaImport = structNew();

JavaImport.io = structNew();
JavaImport.io.File = CreateObject('java', 'java.io.File');

JavaxImport = StructNew();

JavaxImport.imageio = StructNew();
JavaxImport.imageio.ImageIO = CreateObject('java', 'javax.imageio.ImageIO');

imageBuffer = JavaxImport.imageio.ImageIO.read(JavaImport.io.File.Init(imagePath));

response = getPageContext().getFusionContext().getResponse();
response.setHeader('Content-Type', 'image/png');
response.setHeader('Cache-Control', 'max-age=604800, public');
JavaxImport.imageio.ImageIO.write(imageBuffer, "png", response.getResponse().getOutputStream() );

After consulting Railo documentation on GetPageContext method, we’ve come to the following result:

JavaImport = structNew();

JavaImport.io = structNew();
JavaImport.io.File = CreateObject('java', 'java.io.File');

JavaxImport = StructNew();

JavaxImport.imageio = StructNew();
JavaxImport.imageio.ImageIO = CreateObject('java', 'javax.imageio.ImageIO');

imageBuffer = JavaxImport.imageio.ImageIO.read(JavaImport.io.File.Init(imagePath));

response = getPageContext();
response.setHeader('Content-Type', 'image/png');
response.setHeader('Cache-Control', 'max-age=604800, public');
JavaxImport.imageio.ImageIO.write(imageBuffer, "png", response.getResponseStream() );

How it will be useful to you as well.

Cirjan Dragos
No Comments

Post a Comment