Roland, Thanks, got clear now. In your experience, does the type attribute matter in the cfcontent tag, or can i use image/gif for jpeg's and png's as well.
>-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >Behalf Of Roland Collins >Sent: Thursday, October 06, 2005 9:09 PM >To: [email protected] >Subject: RE: [CFCDev] ImageCache experiments > > >Sorry - I meant that specifically instead of Dave's pageContext hack. In >his case, it should work well. > >We use cfcontent in another page and then use that as the image url. IMO, >you should use your original "backup" plan, as others have suggested. That >template, if it's _that_ frequently used, will stay cached in >memory by both >CF, and likely by the OS as well, so the HD hit should be minimal or >non-existent. > >-----image.cfm----- ><cfcontent type="image/gif" >variable="#application.ImageCache.getImage(url.image)#"> ></cfcontent> >------------------- > >Then in your main page, just write a normal image tag: > >-----anypage.cfm----- ><img src="image.cfm?image=myImage.gif"> >--------------------- > >Roland > >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf >Of Nando >Sent: Thursday, October 06, 2005 2:58 PM >To: [email protected] >Subject: RE: [CFCDev] ImageCache experiments > >I tried , but cfcontent cuts off all other textual output on the >template if >i place with other content. I need it inline. The docs even say that's how >it should behave when using the variable attribute. The reset attribute is >disabled when the variable attribute is used. > >Is there a trick to get that to work? I tried for quite awhile. > >>-----Original Message----- >>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >>Behalf Of Roland Collins >>Sent: Thursday, October 06, 2005 8:42 PM >>To: [email protected] >>Subject: RE: [CFCDev] ImageCache experiments >> >> >>Why not just use cfcontent? >> >><cfcontent type="image/gif" variable="#imgContent#"></cfcontent> >> >>Roland >> >>-----Original Message----- >>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf >>Of David Ross >>Sent: Thursday, October 06, 2005 11:08 AM >>To: [email protected] >>Subject: RE: [CFCDev] ImageCache experiments >> >>We stream a lot of images from databases, which is similar to what >>you're doing. You might want to compare the performance of cfcontent >>with pushing the bytes w/ java. It's probably similar code under the >>hood... but might as well check. >> >>assuming imgContent contains your bytes: >> >><cfset ctx = getPageContext()/> >><cfset ctx.setFlushOutput(false)/> >><cfset response = ctx.getResponse().getResponse()/> >><cfset out = response.getOutputStream()/> >><cfset response.setContentType("image/jpeg")/> >><cfset response.setContentLength(arrayLen(imgContent))/> >><cfset out.write(imgContent)/> >><cfset out.flush()/> >><cfset out.close()/> >> >>I think I originally pulled this off Christian Cantrell's blog, so >>thanks to him! >> >>-Dave >> >> >>>>> [EMAIL PROTECTED] 10/06/05 10:57 AM >>> >>Thanks Dave! >> >>I'm going to try to deploy this and see if it helps. I assumed the .cfm >>would generate a hit to the HD, but wasn't sure. I also wasn't sure if >>there >>was a better way around this. Sounds good. The .cfm will be called 100's >>if >>not thousands of times per second under load. >> >>>-----Original Message----- >>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >>>Behalf Of David Ross >>>Sent: Thursday, October 06, 2005 2:47 PM >>>To: [email protected] >>>Subject: Re: [CFCDev] ImageCache experiments >>> >>> >>>you can't inline image bytes with other character-based content... >>>that's the whole purpose of the <img /> tag. I'm not sure why you think >>>using a separate .cfm to push down the image is introducing disk >>>activity... once CF parses your .cfm into a servlet it's pretty much in >>>memory AFAIK, especially if hit often. Your second approach is the >>>correct (and only) way to do it. >>> >>>-Dave >>> >>>>>> [EMAIL PROTECTED] 10/06/05 3:32 AM >>> >>>Hi, >>> >>>I'm trying to work out a way to cache binary image data in an >>>application >>>scoped CFC and output it directly to the output stream without needing >>>to >>>hit the hard disk at all. The objective is to tweak all the performance >>>i >>>can get out of a server. >>> >>>Here's what i've got so far: >>> >>>-- >>>ImageCache.cfc >>>------------------------------------------------------------ >>> >>><cfcomponent displayname="ImageCache"> >>> >>> <cffunction name="init" access="public" returntype="ImageCache" >>>output="false"> >>> <cfargument name="imagePaths" required="Yes" >>>type="string" hint="Comma >>>delimited list of fully qualified paths to directories with images to >>>cache >>>in memory" /> >>> <cfset variables.imagePaths = >>>listToArray(arguments.imagePaths) /> >>> <cfset cacheImageData() /> >>> <cfreturn this /> >>> </cffunction> >>> >>> <cffunction name="cacheImageData" access="private" >>>returntype="void" >>>output="false"> >>> <cfset var imagePath = "" /> >>> <cfset var imageNames = "" /> >>> <cfset var imageKey= "" /> >>> <cfset var binImage = 0 /> >>> <cfloop from="1" to="#arrayLen(variables.imagePaths)#" >>>index="i"> >>> <cfdirectory action="LIST" >>>directory="#variables.imagePaths[i]#" >>>name="imageNames" /> >>> <cfloop query="imageNames"> >>> <cfif >>>ListContains("gif,jpg,jpeg,png,bmp",ListLast(imageNames.name, >>>"."))> >>> <cffile action="readBinary" >>>file="#variables.imagePaths[i]##imageNames.name#" variable="binImage"> >>> <cfset imageKey = >>>Replace(imageNames.name, ".","","all") /> >>> <cfset >>>variables[imageKey]['data'] = binImage /> >>> <cfset >>>variables[imageKey]['type'] = ListLast(imageNames.name, ".") /> >>> </cfif> >>> </cfloop> >>> </cfloop> >>> </cffunction> >>> >>> <cffunction name="getImage" access="public" returntype="any" >>>output="false"> >>> <cfargument name="imageName" required="Yes" >>>type="string" /> >>> <cfset var imageKey = Replace(arguments.imageName, >>>".","","all") /> >>> <cfset var image = "missing" /> >>> >>> <cfif StructKeyExists(variables,imageKey)> >>> <cfsavecontent variable="image"> >>> <cfcontent >>>type="image/#variables[imageKey]['type']#" reset="No" >>>variable="#variables[imageKey]['data']#"> >>> </cfsavecontent> >>> </cfif> >>> <cfreturn image /> >>> </cffunction> >>> >>></cfcomponent> >>>------------------------------------------------------------------- >>>--------- >>> >>>-- imageCacheTest.cfm -- >>> >>><cfif NOT StructKeyExists(application, "ImageCache") OR >>>StructKeyExists(url, >>>"reset")> >>> <cfset currentDirectory = >>>GetDirectoryFromPath(GetTemplatePath())> >>> <cfset application.ImageCache = >>>createObject('component','ImageCache').init(currentDirectory)> >>></cfif> >>> >>><cfoutput> >>>Other content??? >>> >>>#application.ImageCache.getImage('adminGreen.gif')# >>> >>></cfoutput> >>>------------------------------------------------------------------- >>>--------- >>> >>>What's happening is that the cfcontent tag in the CFC is preventing any >>>other content from being displayed on imageCacheTest.cfm >>> >>>I do have something working, but it involves introducing a small hit to >>>the >>>hard disk like so. >>> >>>-- image.cfm >>>--------------------------------------------------------------- >>> >>><cfoutput> >>>#application.ImageCache.getImage(url.image)# >>></cfoutput> >>>------------------------------------------------------------------- >>>--------- >>> >>>-- imageCacheTest2.cfm >>>---------------------------------------------------- >>> >>><cfif NOT StructKeyExists(application, "ImageCache") OR >>>StructKeyExists(url, >>>"reset")> >>> <cfset currentDirectory = >>>GetDirectoryFromPath(GetTemplatePath())> >>> <cfset application.ImageCache = >>>createObject('component','ImageCache').init(currentDirectory)> >>></cfif> >>> >>>Other content??? >>> >>><img src="image.cfm?image=arrows_small.gif" alt="" border="0" /> >>> >>>------------------------------------------------------------------- >>>--------- >>> >>>My thinking is that this may help under load, because it minimizes the >>>hit >>>to the hard disk, but i'd like to eliminate it completely. >>> >>>Anyone have any suggestions? >>> >>>thanks, >>>Nando >>> >>> >>> >>> >>> >>>---------------------------------------------------------- >>>You are subscribed to cfcdev. To unsubscribe, send an email to >>>[email protected] with the words 'unsubscribe cfcdev' as the subject >>of >>>the email. >>> >>>CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting >>>(www.cfxhosting.com). >>> >>>CFCDev is supported by New Atlanta, makers of BlueDragon >>>http://www.newatlanta.com/products/bluedragon/index.cfm >>> >>>An archive of the CFCDev list is available at >>>www.mail-archive.com/[email protected] >>> >>> >>> >>> >>> >>>---------------------------------------------------------- >>>You are subscribed to cfcdev. To unsubscribe, send an email to >>>[email protected] with the words 'unsubscribe cfcdev' as the >>>subject of the email. >>> >>>CFCDev is run by CFCZone (www.cfczone.org) and supported by >>>CFXHosting (www.cfxhosting.com). >>> >>>CFCDev is supported by New Atlanta, makers of BlueDragon >>>http://www.newatlanta.com/products/bluedragon/index.cfm >>> >>>An archive of the CFCDev list is available at >>>www.mail-archive.com/[email protected] >>> >>> >> >> >> >> >> >>---------------------------------------------------------- >>You are subscribed to cfcdev. To unsubscribe, send an email to >>[email protected] with the words 'unsubscribe cfcdev' as the subject of >>the email. >> >>CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting >>(www.cfxhosting.com). >> >>CFCDev is supported by New Atlanta, makers of BlueDragon >>http://www.newatlanta.com/products/bluedragon/index.cfm >> >>An archive of the CFCDev list is available at >>www.mail-archive.com/[email protected] >> >> >> >> >> >>---------------------------------------------------------- >>You are subscribed to cfcdev. To unsubscribe, send an email to >>[email protected] with the words 'unsubscribe cfcdev' as the >>subject of the >>email. >> >>CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting >>(www.cfxhosting.com). >> >>CFCDev is supported by New Atlanta, makers of BlueDragon >>http://www.newatlanta.com/products/bluedragon/index.cfm >> >>An archive of the CFCDev list is available at >>www.mail-archive.com/[email protected] >> >> >> >> >> >> >> >>---------------------------------------------------------- >>You are subscribed to cfcdev. To unsubscribe, send an email to >>[email protected] with the words 'unsubscribe cfcdev' as the >>subject of the email. >> >>CFCDev is run by CFCZone (www.cfczone.org) and supported by >>CFXHosting (www.cfxhosting.com). >> >>CFCDev is supported by New Atlanta, makers of BlueDragon >>http://www.newatlanta.com/products/bluedragon/index.cfm >> >>An archive of the CFCDev list is available at >www.mail-archive.com/[email protected] > > > > > > >---------------------------------------------------------- >You are subscribed to cfcdev. To unsubscribe, send an email to >[email protected] with the words 'unsubscribe cfcdev' as the >subject of the >email. > >CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting >(www.cfxhosting.com). > >CFCDev is supported by New Atlanta, makers of BlueDragon >http://www.newatlanta.com/products/bluedragon/index.cfm > >An archive of the CFCDev list is available at >www.mail-archive.com/[email protected] > > > > > > > >---------------------------------------------------------- >You are subscribed to cfcdev. To unsubscribe, send an email to >[email protected] with the words 'unsubscribe cfcdev' as the >subject of the email. > >CFCDev is run by CFCZone (www.cfczone.org) and supported by >CFXHosting (www.cfxhosting.com). > >CFCDev is supported by New Atlanta, makers of BlueDragon >http://www.newatlanta.com/products/bluedragon/index.cfm > >An archive of the CFCDev list is available at >www.mail-archive.com/[email protected] > > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
