1

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

Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
George Murphy
  • 937
  • 2
  • 10
  • 16
  • 3
    [Last I checked](http://stackoverflow.com/a/12310570/104223) the issue was due to lack of support for cmyk in the underlying library: javax.ImageIO. (Glancing at the source, imgscalr uses ImageIO as well, BTW). I have not tried it, but [supposedly JAI 1.1 supports CMYK](http://pbrajkumar.wordpress.com/2013/01/09/read-cmyk-image-in-java/). Failing that you might need to convert the image to RGB format. One option is using ImageMagick via cfexecute. – Leigh Aug 08 '13 at 19:49
  • 2
    Also, if you search the archives, there are many threads on converting cmyk->rgb in java (with varying levels of success). For example: [1](http://stackoverflow.com/questions/2408613/problem-reading-jpeg-image-using-imageio-readfile-file) , [2](http://stackoverflow.com/questions/22409/how-do-i-convert-images-between-cmyk-and-rgb-in-coldfusion-java) , [3](http://stackoverflow.com/a/12132630/104223) – Leigh Aug 08 '13 at 19:50

0 Answers0