Posts Tagged ‘images’
Get filename from path
Monday, June 14th, 2010
Ever want to extract the filename from a path? C:\Inetpub\wwwroot\website\app\config\template\abc.jpg
... And not want to code something stupidly insane.
Try using #GetFileFromPath("C:\Inetpub\wwwroot\website\app\config\template\abc.jpg")#
So...
<cfset source=" C:\Inetpub\wwwroot\website\app\config\template\abc.jpg" />
<cfset fileName = GetFileFromPath(source) />
If your variable is a URL, you can't use GetFileFromPath (because it needs relative paths on your computer/network) - try using #ListAtLast("http://www.example.com/example.jpg","/")#
Once again...
<cfset source=" http://www.example.com/example.jpg" />
<cfset fileName = ListAtLast(source,"/") />…
Downloading an image from database
Friday, June 11th, 2010A project I'm working on involves storing asset references in a database and then later downloading the images. Why? because it takes bloody ages!
So assuming you have a table called Assets, and all the right fields. There's two options, using cfhttp or cfimage (cf8+).
<cfset pathToActualImage = "http://www.google.com/images/hello.jpg" />
<cfset tempFileName = "test.jpg" />
<cfset tempPath = "C:\temp\" />
<cfhttp url="#pathToActualImage#" file="#tempFileName#" path="#tempPath#">
Or
<cfimage action="write" destination="#tempFileName##tempPath#" source="#pathToActualImage#" />
I'd recommend to maybe use cfimage because
Adding a watermark to original images on the fly
Monday, March 1st, 2010
Found this great piece of code that will allow you to prevent users or atleast stop them a little... from downloading your images. Using the cfimage tag!
Simply use cfimage to call you're first two images, then using ImagePaste() to mash them together, and write to the browser calling '#image#'.
See how you go.
<cfimage source=”img_2566.jpg” name=”image”>
<cfimage source=”watermark.png” name=”watermark”>
<cfset ImagePaste(image, watermark… Continue reading