Search code examples
phpcoldfusioncoldfusion-8

PHP/Coldfusion image resize


Is it possible to add php image resize code to my coldfusion page? Images look significantly sharper when resized by php instead of coldfusion(even when I use the coldfusion's imageResize "highestquality" option).

<cfftp action="PUTFILE"
                       server="#ATTRIBUTES.FtpServer#" 
                       username="#ATTRIBUTES.FtpUsername#"
                       password="#ATTRIBUTES.FtpPassword#"
                       stoponerror="No"
                       localfile="#ATTRIBUTES.LOCALIMAGEFILE#"
                       remotefile="#Filename_Temp#"
                       transfermode="BINARY"
                       connection="DOCMGR"
                       retrycount="1"
                       timeout="60" 
                       passive="Yes">
<!-- Add php resize image code here -->

Solution

  • If you can run PHP and ColdFusion on the same server, upload using CF and store the file in a common location. Cfhttp GET a separate PHP page which resizes the image to your specifications. Then the caller CF page would do what it needs to with the image.

    If you cant get PHP and CF on the same server, you could always cfhttp POST the image to the other server. Make sure you use a multi-part form post, otherwise you'll lose data on images >~ 1mb.

    If you're ftping the file from CF to another server, you could http post the image to PHP which could resize then ftp the new image for you without having to send it back to CF first.

    The other option is calling imagemagick directly using the command line, ie. cfexecute. You'll get better performance calling imagemagick directly, rather than having php pass on the request. Unless of course, you want to use php to programatically alter the images. You should be able to achieve the same results with well crafted command line calls though.