Hi All,
I'm using this tag to grab an image file uploaded by an end user through
a "file" form field.

I want to convert it to jpg and resize it if necessary (borrowing from a
CFDJ article.

Three issues:

1) I keep seeing in the HOF list archives that developers are using an
ACTION="iml", though I can't find documentation for that attribute
anywhere in the CFX_Image docs (v1.6.6.9).  What does this Attribute do?

2) If I need to do a two-step process, for example, resizing the image
AND converting the file to another format, should I first resize, then
park the output in a temp directory, then in the second step, grab the
image from the temp directory then output to the final directory?

3) After the conversion/resizing process, I want to grab the full file
path, then write this info to a database. How do I get the final image
name and CFSET as a variable, so I can do a db insert.

I've attached my code below (note that I'm Cfincluding this, so that db
inserts won't be listed here):

Thanks,
Mark

========================================

<!--- Set the variables for use in this template
/////////////////////////////////////////////////////////////////--->
        <!--- List of process type variables +++++++++
                Resizing:
                        Resize Dimensions = resizedim in pixels
                File Type Conversion
                        B1 = convert to jpg,    B2 = convert to gif
        +++++++++++++++++++++++++++++++++ --->
        
        <!--- Resizing properties --->
                <cfset VARIABLES.resizedim = 300>
                        
        <!--- File Conversion Properties --->
                <cfset VARIABLES.converttype = B1>

        <!--- Other Parameters --->
                <cfset VARIABLES.formFile = FORM.biopic>

        <!--- Temporary Processing Image Path Location --->
                <cfset REQUEST.tempPics =
"#REQUEST.absolutepath#\admin\processpics\">
                
        <!--- Final Image Location --->
                <cfset REQUEST.picPath =
"#REQUEST.absolutepath#\photos\">

<!--- End the variables set
////////////////////////////////////////////////////////////////////////
////////--->

<!--- Start the file conversion process
////////////////////////////////////////////////////////////////////////
/ --->

                <!--- Call the Tag and retreive the uploading file
attributes using the read command --->
                <cflock name="imageprocess" timeout="10"
type="exclusive">
                
                <cfif #VARIABLES.formFile# NEQ ""> 
                        <CFX_Image FILE="#VARIABLES.formFile#"
ACTION="READ"> 

                <!--- Determines the final file type format depending on
the variables set above --->
                        <cfswitch expression="#VARIABLES.converttype#">
                        
                                <cfcase value="B1"> <!--- convert to jpg
--->
                                                <!--- If the image is
already a jpg --->
                                                <cfif #IMG_TYPE# IS
"JPEG">
                                                        <!--- If the
image size is greater than a specified dimension, resize it --->
                                                        <cfif
#IMG_HEIGHT# GT #VARIABLES.resizedim#>
        
<CFX_Image ACTION="RESIZE"
        
FILE="#VARIABLES.formFile#"
        
OUTPUT="#REQUEST.picPath##VARIABLES.formFile#.jpg"
        
BITCOUNT="24"
        
QUALITY="100"
        
Y="#VARIABLES.resizedim#">
                                                        <!--- If the
image size meets the size parameters, just copy it to a temp directory
--->
                                                        <cfelse>
        
<CFX_Image ACTION="COPY"
        
FILE="#VARIABLES.formFile#"
        
OUTPUT="#REQUEST.picPath##VARIABLES.formFile#.jpg">
                                                        </cfif> 
                                        
                                        <!--- If the image is not a jpg,
convert it to this format --->
                                        <cfelse>
                                                <!--- If the image size
is greater than a specified dimension, and its not a jpg, resize then
convert --->
                                                <cfif #IMG_HEIGHT# GT
#VARIABLES.resizedim#>
                                                        <CFX_IMAGE
ACTION="CONVERT"
        
FILE="#VARIABLES.formFile#"
        
OUTPUT="#REQUEST.picPath##VARIABLES.formFile#.jpg"
        
QUALITY="100"> 
                                
                                                        <CFX_IMAGE
ACTION="RESIZE"
        
FILE="#REQUEST.picPath##VARIABLES.formFile#.gif"
        
OUTPUT="#REQUEST.picPath##VARIABLES.formFile#.jpg"
        
BITCOUNT="24"
        
QUALITY="100"
        
Y="#VARIABLES.resizedim#">
                                                                
                                                <!--- If the image meets
the size parameter, just convert the file to jpg --->
                                                <cfelse>
                                                        <CFX_IMAGE
ACTION="CONVERT"
        
FILE="#VARIABLES.formFile#"
        
OUTPUT="#REQUEST.picPath##VARIABLES.formFile#.jpg"
        
TYPE="JPEG"
        
QUALITY="100">
                                                </cfif>
                                        </cfif>
                                </cfcase>
                                
                                <cfcase value="B2"> <!--- convert to gif
--->

                                <!--- Code removed here for brevity --->

                                </cfcase>
                        
                        </cfswitch>
                        
                        <!--- Read the final file format so that the URL
can be written to the database --->
                        <CFX_Image
FILE="#REQUEST.picPath##VARIABLES.formFile#" ACTION="READ"> 
                        
                        <cfset  VARIABLES.formfile =    
                        
        </cflock>
<!--- End the file conversion process
////////////////////////////////////////////////////////////////////////
//////// --->



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to