Here's a routine I used for uploading an image to a folder named,
"ImagesToDelete",
renaming it to remove undesirable characters in the filename, then creating
the 3 different
sizes for site use.  The <cfset... statements create a variable that is the
same as the
database field name that I use in the insert statement.

Concerning putting the original in the "ImageToDelete" folder...  Normally,
I would just delete
the original after creating the other sizes I need, but I'm using the
release candidate of
Windows 7 and found that I couldn't delete the original right away.  So I
simply move it to
a folder (ImagesToDelete) where I run a scheduled task every hour to delete
any files in that
folder.

hth,

Rick


<cffile  action        = "upload"
         filefield     = "#imageFileField#"
         destination   = "#expandPath('/imagesToDelete/')#"
         accept        = "image/jpg, image/pjpg, image/jpeg, image/pjpeg"
nameconflict="makeunique" />
                                                                        
<cfset   renamedOriginal = rereplace(#cffile.serverFileName#,
'[^a-zA-Z0-9.]', '', 'all') />
                                                                        
<cffile  action        = "rename"
         source        =
"#expandPath('/imagesToDelete/')##cffile.serverFile#"
         destination   =
"#expandpath('/imagesToDelete/')##renamedOriginal#.#cffile.serverFileExt#"
/>
                                                                        
                                                                        
<cfimage action        = "resize"
         width         = "200"
         height        = ""
         source        =
"#expandPath('/imagesToDelete/')##renamedOriginal#.#cffile.serverFileExt#"
         destination   =
"#expandPath('/holtzmanRentals/user_images/')##renamedOriginal#w200.#cffile.
serverFileExt#"
         overwrite     = "yes" />
                        
<cfset   photo200      = "#renamedOriginal#w200.#cffile.serverFileExt#" />

                                                        
<cfimage action        = "resize"
         width         = "75"
         height        = "50"
         source        =
"#expandPath('/imagesToDelete/')##renamedOriginal#.#cffile.serverFileExt#"
         destination   =
"#expandPath('/holtzmanRentals/user_images/')##renamedOriginal#w75h50.#cffil
e.serverFileExt#" overwrite="yes" />
                                                        
<cfset   photo75x50    = "#renamedOriginal#w75h50.#cffile.serverFileExt#" />
                                                                
<cfimage action        = "resize"
         width         = "458"
         height        = "306"
         source        =
"#expandpath('/imagesToDelete/')##renamedOriginal#.#cffile.serverFileExt#"
         destination   =
"#expandPath('/holtzmanRentals/user_images/')##renamedOriginal#w458h306.#cff
ile.serverFileExt#"
         overwrite     = "yes" />
                                                        
<cfset   photo458x306  = "#renamedOriginal#w458h306.#cffile.serverFileExt#"
/>


        
-----Original Message-----
From: Keith McGee [mailto:[email protected]] 
Sent: Tuesday, September 29, 2009 6:56 AM
To: cf-talk
Subject: Resizing images on upload


Is there a way to resize a users image when they upload it? I want to have
the image formated smaller so it doesn't take up unessasary space on the
server and use up unessasary bandwith viewing the image.

Coldfusion program would be nice but will try anything.

Keith





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326736
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to