Part 1 - Massimo's tmt_img.cfc "Anyone"

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Part 1 - Massimo's tmt_img.cfc "Anyone"

    If anyone here can help me out with this I would be forever grateful

    I need to change the image directory path in this CFC. Currently it works
    great as long as the images reside in the same folder. However, the images I
    need to work with are not in this folder.

    The way it is now I have these two files(form & CFC) in the admin folder.
    /shop/admin/. the image are in /shop/assets/folder1, /shop/assets/folder2/
    etc.

    I am using this on a admin file form.and trying to use it to automatically
    generate a thumbnail image from one larger image.

    The form with this CFC is as follows

    **********************************************

    THE FORM

    <cfprocessingdirective pageencoding="iso-8859-1">
    <cfparam name="form.imagepath" default="minitrain.jpg" type="string">

    <cfif StructKeyExists(form, "submit")>
    <cfscript>
    imgObj=CreateObject("component", "tmt_img");
    imgObj.resize(form.imagepath, "thumb_#form.imagepath#", 250);
    imgObj.crop(form.imagepath, "crop_#form.imagepath#");
    </cfscript>
    </cfif>

    <!---
    /**
    * Turn any system path, either local or absolute, into a fully qualified one
    * @output suppressed
    * @param path (string) Required. Abstract pathname
    * @return string
    */
    --->
    <cffunction name="getAbsolutePath" output="false" returntype="string"
    hint="Turn any system path, either local or absolute, into a fully qualified
    one">
    <cfargument name="path" type="string" required="true" hint="Abstract
    pathname">
    <cfscript>
    var jFile = createObject("java","java.io.File").init(arguments .path);
    if(jFile.isAbsolute()){
    return arguments.path;
    }
    else{
    return ExpandPath(arguments.path);
    }
    </cfscript>
    </cffunction>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>tmt_img sample</title>
    <link href="style_distro.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <form name="form1" method="post"
    action="<cfoutput>#GetFileFromPath(GetTemplatePath ())#</cfoutput>">
    <p> Just a very basic demonstration of resize and crop </p>
    <p>Image name:</p>
    <p><input type="text" name="imagepath" style="width: 300px"
    value="<cfoutput>#form.imagepath#</cfoutput>" /></p>
    <p><input type="submit" name="submit" value="Process image" /></p>
    </form>
    <cfif FileExists(getAbsolutePath(form.imagepath))>
    <p><img src="<cfoutput>#form.imagepath#</cfoutput>" /></p>
    </cfif>
    <cfif FileExists(getAbsolutePath("thumb_#form.imagepath# "))>
    <p>resize: <img src="<cfoutput>thumb_#form.imagepath#</cfoutput>" /></p>
    </cfif>
    <cfif FileExists(getAbsolutePath("crop_#form.imagepath#" ))>
    <p>crop: <img src="<cfoutput>crop_#form.imagepath#</cfoutput>" /></p>
    </cfif>
    </body>
    </html>


    Bill Guest

  2. Similar Questions and Discussions

    1. Why is "Act as part of the operating system" dangerous?
      Hello everybody: I have a question: Why is "Act as part of the operating system" dangerous? I have an application that will go live on Windows...
    2. Windows Server 2003/IIS 6.0/ASP.NET "Could not find a part of the path"
      I have an ASP.NET web application running on a load-balanced Windows Server 2003 web farm running IIS 6.0, using Active Directory authentication. ...
    3. Exception - Could not find a part of the path "D:\"
      I've just deployed my .Net Web app at an ISP on a shared server. Whenever I try to create a new directory, an exception is raised - Could not...
    4. lost part of my "/usr/local"-filesystem - debian(woody)
      Hi all, I inadvertently deleted part of my "/usr/local"-filesystem doing a "rm -r /usr/local". Although I stopped the command immediately when I...
    5. Sony DSC-F1 Video Connector?? "Battery adapter attaching part"???
      Sony DSC-F1 Video Connector? What's the connector for the DSC-F1 Video Out? If I stuff in a 1/8" phone plug, I get video out. Problem is that...
  3. #2

    Default Re: Part 2 - Massimo's tmt_img.cfc "Anyone"

    I couldn't post Part 2 as it was to large so I've uploaded the Text file.

    The whole works is here [url]http://www.datapacks.com/img_CFC.txt[/url]

    Thanks in advance

    Bill



    Bill Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139