Oh ya...and use those AFTER you upload the file via CFFILE ;-)

Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
t. 250.920.8830
e. [EMAIL PROTECTED]

---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com
  ----- Original Message -----
  From: Bryan Stevenson
  To: CF-Talk
  Sent: Wednesday, June 09, 2004 11:49 AM
  Subject: Re: image dimensions

  If you're on CF MX...here are 2 usefil functions you can drop ina CFC:

    <!---(Function: FileSize)------------------------------------------------------
    Date Created:   March 12, 2004
    Author:         Phil
    Arguments:      FileLoc - full path of file (string) required
    Purpose:        Gets the size of a file in bytes
    Returns:        File Size in bytes (numeric)
    --->
    <cffunction name="FileSize" returnType="numeric" access="public">
      
      <cfargument name="FileLoc" type="string" required="Yes">

      <cfset jFileIn = CreateObject("java","java.io.File").init(ARGUMENTS.FileLoc)>
      <cfreturn jFileIn.Length()>
      
    </cffunction>
   

    <!---(Function: ImageSize)------------------------------------------------------
    Date Created:   November 28, 2003
    Author:         Bryan
    Arguments:      FileLoc - full path of image to get details for (string) required
    Purpose:        returns file width/height
    Returns:        ImageInfo structure with ImgWidth/ImgHeight keys
    --->
    <cffunction name="ImageSize" returnType="struct" access="public">
      
      <cfargument name="FileLoc" type="string" required="Yes">  
      
      <cfset jFileIn = createObject("java","java.io.File").init(ARGUMENTS.FileLoc)>
           
      <cfset ImageInfo = StructNew()>
      <cfset ImageObject = createObject("java","javax.imageio.ImageIO").read(jFileIn)>
      
      <cfset ImageInfo.ImgWidth = ImageObject.getWidth()>
      <cfset ImageInfo.ImgHeight = ImageObject.getHeight()>
      
      <cfreturn ImageInfo>

    </cffunction>

  Enjoy ;-)

  Bryan Stevenson B.Comm.
  VP & Director of E-Commerce Development
  Electric Edge Systems Group Inc.
  t. 250.920.8830
  e. [EMAIL PROTECTED]

  ---------------------------------------------------------
  Macromedia Associate Partner
  www.macromedia.com
  ---------------------------------------------------------
  Vancouver Island ColdFusion Users Group
  Founder & Director
  www.cfug-vancouverisland.com
    ----- Original Message -----
    From: Daniel Kessler
    To: CF-Talk
    Sent: Wednesday, June 09, 2004 11:37 AM
    Subject: image dimensions

    I have a file upload button, which seems to work fine.  It'd be good
    to know the image dimensions at some point in the process so I can
    proportionately adjust it's size.  If I can get the size when I
    select the image which has been Browse-> selected from the hard
    drive, or get it during the upload (CFFile) or at display time, I can
    do some sort of "size containment", if it's too large at least.

    --
    Daniel Kessler

    Department of Public and Community Health
    University of Maryland
    Suite 2387 Valley Drive
    College Park, MD  20742-2611
    301-405-2545 Phone
    www.phi.umd.edu
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to