Skip to main content
Known Participant
March 25, 2009
Answered

image scale to fit to file

  • March 25, 2009
  • 1 reply
  • 1144 views
I am trying to save my image to file once I have scaled it. Trying the code attached but get an error. Can I save the file directly with <cfimage> or do I use <cffile>

Thanks.

    This topic has been closed for replies.
    Correct answer -__cfSearching__-
    Thanks for your help, my line does have "write" permissions set, is this the line you mean?

    <cfimage source="#thumbImage#" action="write" destination="#destination#">

    Attached is the full code,

    As I understand it the full image is loaded into the gallery folder, the server file is read and scaled with

    <cfset svrFile = "#File.ServerFile#" />
    <cfimage name="thumbImage" source="#ExpandPath("#application.galleryPath##galleryName#/#svrFile#")#" />
    <cfset ImageScaleToFit(thumbImage,200,"","bicubic")>

    The last bit is where the problem is where it it trying to write the file

    <cfset destination="#application.galleryPath##galleryName#/thumbs/#svrFile#">
    <cfimage source="#thumbImage#" action="write" destination="#destination#">

    Is it trying to use svrFile and scale and save it at the same time?





    > An exception occured while trying to write the image.
    > Ensure that the destination directory exists and that Coldfusion has permission to write to

    That is a bug. Check your patches. There was a fix for that issue:

    Patch for CFImage and Image functions in ColdFusion 8.0.1
    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403411

    1 reply

    Inspiring
    March 25, 2009
    Hi,

    Can you please post the exact error message here?..

    Inspiring
    March 25, 2009
    Hi,

    You can try it like this,

    HulfyAuthor
    Known Participant
    March 25, 2009
    What was tripping me up is I did not know I had to supply the full path, with file name.

    I still get an upload error but this time it is a permissions error, even if I take the path back from 'thumbs' to the folder where the original image is it still does not upload the image.


    An exception occured while trying to write the image.
    Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : coldfusion.image.ImageWriter$ImageWritingException: An exception occured while trying to write the image.