Resizing Images using Java

461 views Asked by At

I am using ColdFusion 9.0.1 to handle all of our image resizing. It works great except for certain jpegs that are CMYK or have a certain ICC profile.

I am trying a java solution.

imgscalrPath    =   ExpandPath( "imgscalr-lib-4.2.jar" );
loader  =   New javaloader.javaLoader( [ imgscalrPath ] );
Scalr   =   loader.create( "org.imgscalr.Scalr" );
mode    =   loader.create( "org.imgscalr.Scalr$Mode" );
method  =   loader.create( "org.imgscalr.Scalr$Method" );
sourceImage =   ImageNew( "DSC01040.jpg" );
bufferedImage   =   ImageGetBufferedImage( sourceImage );
smallerImage    =   Scalr.resize( bufferedImage,method.SPEED,mode.FIT_TO_WIDTH,250,[] );
ImageWrite( ImageNew( smallerImage ),"hello.jpg" );

The issue is that ColdFusion throws an Error starting with the imageNew method saying invalid file type. So are there any Java Methods that I can use for the two lines of code below?

sourceImage =   ImageNew( "source.jpg" );
bufferedImage   =   ImageGetBufferedImage( sourceImage );

The solution cannot be .dll files (Not accepted by security). Running on 64 BIT machines

0

There are 0 answers