Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,360 members, 7,819,292 topics. Date: Monday, 06 May 2024 at 01:49 PM

What's Your Favourite Coldfusion Tag - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / What's Your Favourite Coldfusion Tag (1662 Views)

Available: Mp3 Tag Script & Video Url Upload Script With File Rename / What's Your Favourite IDE For Java? / What Is Your Favourite Php Framework (2) (3) (4)

(1) (Reply) (Go Down)

What's Your Favourite Coldfusion Tag by penyng: 10:14pm On Feb 13, 2007
you are all invited to show-forth your favourite coldfusion tag

mine

<cfquery name="getcfprogrammers" datasource="nairaland">
SELECT CFPROGRAMMERS, CFDEVELOPERS, CFM
FROM NAIRALAND
WHERE CFPROGRAMMER.CFML=CFDEVELOPER.CFML
AND CFDEVELOPER.CFX=CFM.CFX
ORDER BY CFM
</cfquery> grin tongue
Re: What's Your Favourite Coldfusion Tag by boraddo(m): 11:57am On Feb 14, 2007
<cftry>
<cfcoup domain="nairaland" admin="seun" newadmin="boraddo" action="overthrow" />

<cfcatch exception="any">
<cfdump var="#error#" >
</cfcatch>

</cftry>
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 1:25pm On Feb 14, 2007
<cfdump var="#nairaland_admin#">
Re: What's Your Favourite Coldfusion Tag by boraddo(m): 2:00pm On Feb 14, 2007
penyng,
u run query u no output am?
Re: What's Your Favourite Coldfusion Tag by penyng: 9:23pm On Feb 15, 2007
<cfoutput>
#nairaland.cfprogrammers#<br>
#nairaland.cfdevelopers#<br>
</cfoutput>
Re: What's Your Favourite Coldfusion Tag by penyng: 9:30pm On Feb 15, 2007
boraddo

please are u a coldfusion user. i use coldfusion but
i feel that most people use php as there application server
i am considering. help
Re: What's Your Favourite Coldfusion Tag by smartsoft(m): 11:09pm On Feb 15, 2007
Coldfusion sucks
Re: What's Your Favourite Coldfusion Tag by sbucareer(f): 10:12am On Feb 16, 2007

How do you know!! smartsoft, it is a language for the weak minded. Very soon people will post that COBOL is the best language for the web.

Why are people stubborn? Later you will see them complaining that they are unemployed. Macromedia like the name suggests are good in media particularly multimedia. I can't understand why they are in the web server side script language business. Jack of all trade becomes Jack of nothing.

CF programmer are expensive to employ because little programmer are in this area. Remember the law of demand and supply. If you employ one CF, they would act as god in your company and you cannot sack them because you cannot afford to get replacement within a time frame and it could be more expensive for the experience CF.

With these fact CF should be thrown inside the burning bush and forget we ever had a script language called CF. MO (My Opinion)
Re: What's Your Favourite Coldfusion Tag by boraddo(m): 1:40pm On Feb 16, 2007
penng,
no mind them,
contrary to what smartsoft ans sbucareer are sayin, CF is actually a very good language, im sure the big bois no that , no wonder 75 out of the fortune 100 companies use it, http://www.adobe.com/products/coldfusion/proven/
i'm an advanced CF user, i code PHP very well too , and i can boldly say that CF rules.
at the moment , top nigerian companiies run on cf .access, schlum, fcmb, e.t.c. (check www.accessbankplc.com , www.zenithbank.com , www.sterlingbankng.com )all these sites run on CF. even MYSPACE is powered by CF.  we've had an argument on nairaland before https://www.nairaland.com/nigeria/topic-27675.0.html so im not tryin to argue,   
if you're already into CF, i'll advice you not to look back
send me a mail shola @ neoplex . net . i might have an opportunity for u.
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 1:54pm On Feb 16, 2007
@sbucareer

I've always respected your posts until now. ColdFusion is a language for the weak-minded? Please you need to base your statements on facts. Check out the code below (component for image resizing) with all the java interfacing and all. Does it still look like a language for the weak minded?


<cfcomponent hint="Get dimensions, crop or resize jpg and png files. Requires ColdFusion 6.1 or above" output="false">

<!--- Ensure this file gets compiled using iso-8859-1 charset --->
<cfprocessingdirective pageencoding="iso-8859-1">

<!--- Set instance variables --->
<cfscript>
// Default imageType is jpg
variables.imgType = "jpg";
// By default the CFC throws an exception if it fails to save an image to disk
variables.throwOnSave = true;
// Rendering hints used for transformations
variables.jHints = createObject("java","java.awt.RenderingHints"wink;
// Set Bilinear as default interpolation type. It may be turned to nearest-neighbor or bicubic using the init() method
variables.interpolationType = variables.jHints.VALUE_INTERPOLATION_BILINEAR;
// Default to a rendering algorithm with a preference for output quality. It may be turned off using the init() method
variables.renderQuality = variables.jHints.VALUE_RENDER_QUALITY;
// Default color rendering to quality. It may be set using the init() method
variables.colorRendering = variables.jHints.VALUE_COLOR_RENDER_QUALITY;
// Dithering is turned on by default. It may be turned off using the init() method
variables.dithering = variables.jHints.VALUE_DITHER_ENABLE;
// Antialiasing is turned off by default. It may be turned on using the init() method
variables.antialiasing = variables.jHints.VALUE_ANTIALIAS_OFF;
// Default to an image-scaling algorithm that gives higher priority to image smoothness than scaling speed. It may be turned on using the init() method
variables.scalingQuality = createObject("java","java.awt.Image"wink.SCALE_SMOOTH;
</cfscript>

<!---
/**
* Pseudo-constructor, it ensure custom settings are loaded inside the CFC.
Use it only if you want to modify default settings
* @access public
* @output suppressed
* @param imgType (string) Optional. Default to jpg. Image type used by the CFC (only jpg or png allowed). Default to jpg
* @param interpolationType (string) Optional. Default to bilinear. By default the CFC use a bilinear algorithm for image interpolation; you can set it to nearest_neighbor or bicubic.
Please note bicubic works only on Java 1.5. See http://java.sun.com/j2se/1.5.0/docs/guide/2d/new_features.html
* @param scalingQuality (boolean) Optional. Default to true. By default the CFC use an image-scaling algorithm that gives higher priority to image smoothness rather than scaling speed.
This is often the most important among all the quality related settings for resize operations.
Turn it off if you prefer to emphasize speed
* @param throwOnSave (boolean) Optional. Default to true. By default the CFC throws an exception if it fails to save an image on disk.
Set this to false if you prefer to have the CFC returning false instead
* @param renderQuality (boolean) Optional. Default to true. By default the CFC use a rendering algorithm with a preference for output quality.
Turn it off if you prefer to emphasize speed
* @param colorRendering (boolean) Optional. Default to true. By default the CFC use a color rendering algorithm with a preference for output quality.
Turn it off if you prefer to emphasize speed
* @param dithering (boolean) Optional. Default to true. By default dithering is turned on, set it to false if you want to turn it off
* @param antialiasing (boolean) Optional. Default to false. By default antialiasing is turned off, set it to false if you want to turn it on
* @exception tmt_img
*/
--->
<cffunction name="init" access="public" output="false" hint="
Pseudo-constructor, it ensure custom settings are loaded inside the CFC.
Use it only if you want to modify default settings">
<cfargument name="imgType" type="string" required="false" default="jpg" hint="
Image type used by the CFC (only jpg or png allowed). Default to jpg">
<cfargument name="interpolationType" type="string" required="false" default="bilinear" hint="
By default the CFC use a bilinear algorithm for image interpolation; you can set it to nearest_neighbor or bicubic.
Please note bicubic works only on Java 1.5. See http://java.sun.com/j2se/1.5.0/docs/guide/2d/new_features.html">
<cfargument name="scalingQuality" type="boolean" required="false" default="true" hint="
By default the CFC use an image-scaling algorithm that gives higher priority to image smoothness rather than scaling speed.
This is often the most important among all the quality related settings for resize operations.
Turn it off if you prefer to emphasize speed">
<cfargument name="throwOnSave" type="boolean" required="false" default="true" hint="
By default the CFC throws an exception if it fails to save an image on disk.
Set this to false if you prefer to have the CFC returning false instead">
<cfargument name="renderQuality" type="boolean" required="false" default="true" hint="
By default the CFC use a rendering algorithm with a preference for output quality.
Turn it off if you prefer to emphasize speed">
<cfargument name="colorRendering" type="boolean" required="false" default="true" hint="
By default the CFC use a color rendering algorithm with a preference for output quality.
Turn it off if you prefer to emphasize speed">
<cfargument name="dithering" type="boolean" required="false" default="true" hint="
By default dithering is turned on, set it to false if you want to turn it off">
<cfargument name="antialiasing" type="boolean" required="false" default="false" hint="
By default antialiasing is turned off, set it to true if you want to turn it on">
<cfif ListFind("jpg,png", arguments.imgType) NEQ 0>
<cfset variables.imgType=arguments.imgType>
<cfelse>
<cfthrow message="Only jpg or png allowed" type="tmt_img">
</cfif>
<cfif ListFind("bilinear,nearest_neighbor,bicubic", arguments.interpolationType) NEQ 0>
<cfscript>
if(arguments.interpolationType EQ "bilinear"wink{
variables.interpolationType = variables.jHints.VALUE_INTERPOLATION_BILINEAR;
}
if(arguments.interpolationType EQ "nearest_neighbor"wink{
variables.interpolationType = variables.jHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
}
if(arguments.interpolationType EQ "bicubic"wink{
variables.interpolationType = variables.jHints.VALUE_INTERPOLATION_BICUBIC;
}
</cfscript>
<cfelse>
<cfthrow message="Only bilinear, nearest_neighbor and bicubic interpolation are supported" type="tmt_img">
</cfif>
<cfscript>
if(arguments.throwOnSave){
variables.throwOnSave = true;
}
else{
variables.throwOnSave = false;
}
// Scaling quality heavily affect the output
if(arguments.scalingQuality){
variables.scalingQuality = createObject("java","java.awt.Image"wink.SCALE_SMOOTH;
}
else{
variables.scalingQuality = createObject("java","java.awt.Image"wink.SCALE_FAST;
}
// Set rendering hints used for transformations, choosing between quality and speed
if(arguments.renderQuality){
variables.renderQuality = variables.jHints.VALUE_RENDER_QUALITY;
}
else{
variables.renderQuality = variables.jHints.VALUE_RENDER_SPEED;
}
if(arguments.colorRendering){
variables.colorRendering = variables.jHints.VALUE_COLOR_RENDER_QUALITY;
}
else{
variables.colorRendering = variables.jHints.VALUE_COLOR_RENDER_SPEED;
}
if(arguments.dithering){
variables.dithering = variables.jHints.VALUE_DITHER_ENABLE;
}
else{
variables.dithering = variables.jHints.VALUE_DITHER_DISABLE;
}
if(arguments.antialiasing){
variables.antialiasing = variables.jHints.VALUE_ANTIALIAS_ON;
}
else{
variables.antialiasing = variables.jHints.VALUE_ANTIALIAS_OFF;
}
</cfscript>
<!--- Return the current instance of the CFC --->
<cfreturn this>
</cffunction>

<!---
/**
* Resize a jpg or png image file
* @access public
* @output suppressed
* @param source (string) Required. Original image path, either local or absolute
* @param destination (string) Optional. Default to #addPrefix(arguments.source)#. Resized image path, either local or absolute
* @param newWidth (numeric) Optional. Default to 100. New width (pixels). Default to 100
* @return boolean
*/
--->
<cffunction name="resize" access="public" output="false" returntype="boolean" hint="Resize a jpg or png image file">
<cfargument name="source" type="string" required="true" hint="Original image path, either local or absolute">
<cfargument name="destination" type="string" required="false" default="#addPrefix(arguments.source)#" hint="Resized image path, either local or absolute">
<cfargument name="newWidth" type="numeric" required="false" default="100" hint="New width (pixels). Default to 100">
<cfscript>
var jFileIn = urlToJavaFile(arguments.source, true);
var jFileOut = urlToJavaFile(arguments.destination);
// Convert the file.io object into a buffered image
var imgBuffer = javaFileToJavaImg(jFileIn);
// Resize the buffered image
var thumb = bufferedResize(imgBuffer, arguments.newWidth);
// Write the resized image to disk
return saveJavaImg(thumb, jFileOut);
</cfscript>
</cffunction>

<!---
/**
* Resize a buffered image
* @access private
* @output suppressed
* @param imgBuffer Required. Java buffered image
* @param newWidth (numeric) Optional. Default to 100. New width (pixels). Default to 100
* @exception tmt_img
*/
--->
<cffunction name="bufferedResize" access="private" output="false" hint="Resize a buffered image">
<cfargument name="imgBuffer" required="true" hint="Java buffered image">
<cfargument name="newWidth" type="numeric" required="false" default="100" hint="New width (pixels). Default to 100">
<cfscript>
// Read original image dimensions
var imhW = arguments.imgBuffer.getWidth();
var imgH = arguments.imgBuffer.getHeight();
// Calculate scale
var scale = arguments.newWidth / imhW;
// Define new dimensions
var scaledW = Int((scale * imhW));
var scaledH = Int((scale * imgH));
// Create the new image object
var outBufferedImg = createJavaImg(scaledW, scaledH);
// Create the Graphics2D object
var jGraphics2D = getJavaGraphics2D(outBufferedImg);
// Creates a scaled version of the source image
var scaledImg = arguments.imgBuffer.getScaledInstance(JavaCast("int", scaledW), JavaCast("int", scaledH), variables.scalingQuality);
</cfscript>
<cftry>
<cfscript>
// Draw the image
jGraphics2D.drawImage(scaledImg, JavaCast("int", 0), JavaCast("int", 0), createJavaObserver());
jGraphics2D.dispose();
</cfscript>
<cfcatch type="any">
<cfthrow message="Failed to resize image #cfcatch.Message#" type="tmt_img">
</cfcatch>
</cftry>
<cfreturn outBufferedImg>
</cffunction>

<!---
/**
* Create a subimage, defined by a specified rectangular region, out of a jpg or png image file
* @access public
* @output suppressed
* @param source (string) Required. Original image path, either local or absolute
* @param destination (string) Optional. Default to #addPrefix(arguments.source, 'crop_')#. Cropped image path, either local or absolute
* @param areaWidth (numeric) Optional. Default to 100. Width of the specified rectangular region (pixel). Default to 100
* @param areaHeight (numeric) Optional. Default to 100. Height of the specified rectangular region (pixel). Default to 100
* @param x (numeric) Optional. Default to 0. Starting coordinate in the x axis (pixel). Default to 0
* @param y (numeric) Optional. Default to 0. Starting coordinate in the y axis (pixel). Default to 0
* @return boolean
*/
--->
<cffunction name="crop" access="public" output="false" returntype="boolean" hint="Create a subimage, defined by a specified rectangular region, out of a jpg or png image file">
<cfargument name="source" type="string" required="true" hint="Original image path, either local or absolute">
<cfargument name="destination" type="string" required="false" default="#addPrefix(arguments.source, 'crop_')#" hint="Cropped image path, either local or absolute">
<cfargument name="areaWidth" type="numeric" required="false" default="100" hint="Width of the specified rectangular region (pixel). Default to 100">
<cfargument name="areaHeight" type="numeric" required="false" default="100" hint="Height of the specified rectangular region (pixel). Default to 100">
<cfargument name="x" type="numeric" required="false" default="0" hint="Starting coordinate in the x axis (pixel). Default to 0">
<cfargument name="y" type="numeric" required="false" default="0" hint="Starting coordinate in the y axis (pixel). Default to 0">
<cfscript>
var jFileIn = urlToJavaFile(arguments.source, true);
var jFileOut = urlToJavaFile(arguments.destination);
// Convert the file.io object into a buffered image
var imgBuffer = javaFileToJavaImg(jFileIn);
// Create the buffered cropped image
var crop = bufferedCrop(imgBuffer, arguments.areaWidth, arguments.areaHeight, arguments.x, arguments.y);
// Write the thumbnail image to disk
return saveJavaImg(crop, jFileOut);
</cfscript>
</cffunction>

<!---
/**
* First resize, then create a subimage, defined by a specified rectangular region, out of a jpg or png image file
* @access public
* @output suppressed
* @param source (string) Required. Original image path, either local or absolute
* @param destination (string) Optional. Default to #addPrefix(arguments.source, 'crop_')#. Cropped/resized image path, either local or absolute
* @param resizeTo (numeric) Optional. Default to 200. Width used to resize the original image. Default to 200
* @param areaWidth (numeric) Optional. Default to 100. Width of the specified rectangular region. Default to 100
* @param areaHeight (numeric) Optional. Default to 100. Height of the specified rectangular region. Default to 100
* @param x (numeric) Optional. Default to 0. Starting coordinate in the x axis (pixel). Default to 0
* @param y (numeric) Optional. Default to 0. Starting coordinate in the y axis (pixel). Default to 0
* @return boolean
*/
--->
<cffunction name="cropResize" access="public" output="false" returntype="boolean" hint="First resize, then create a subimage, defined by a specified rectangular region, out of a jpg or png image file">
<cfargument name="source" type="string" required="true" hint="Original image path, either local or absolute">
<cfargument name="destination" type="string" required="false" default="#addPrefix(arguments.source, 'crop_')#" hint="Cropped/resized image path, either local or absolute">
<cfargument name="resizeTo" type="numeric" required="false" default="200" hint="Width used to resize the original image. Default to 200">
<cfargument name="areaWidth" type="numeric" required="false" default="100" hint="Width of the specified rectangular region. Default to 100">
<cfargument name="areaHeight" type="numeric" required="false" default="100" hint="Height of the specified rectangular region. Default to 100">
<cfargument name="x" type="numeric" required="false" default="0" hint="Starting coordinate in the x axis (pixel). Default to 0">
<cfargument name="y" type="numeric" required="false" default="0" hint="Starting coordinate in the y axis (pixel). Default to 0">
<cfscript>
var jFileIn = urlToJavaFile(arguments.source, true);
var jFileOut = urlToJavaFile(arguments.destination);
// Convert the file.io object into a buffered image
var imgBuffer = javaFileToJavaImg(jFileIn);
// First resize the image and store the resulting buffer
var thumb = bufferedResize(imgBuffer, arguments.resizeTo);
// Create the buffered cropped image
var crop = bufferedCrop(thumb, arguments.areaWidth, arguments.areaHeight, arguments.x, arguments.y);
// Write the resized/cropped image to disk
return saveJavaImg(crop, jFileOut);
</cfscript>
</cffunction>

<!---
/**
* Create a buffered subimage, defined by a specified rectangular region, out of buffered image
* @access private
* @output enabled
* @param imgBuffer Required. Java buffered image
* @param areaWidth (numeric) Optional. Default to 100. Width of the specified rectangular region. Default to 100
* @param areaHeight (numeric) Optional. Default to 100. Height of the specified rectangular region. Default to 100
* @param x (numeric) Optional. Default to 0. Starting coordinate in the x axis (pixel). Default to 0
* @param y (numeric) Optional. Default to 0. Starting coordinate in the y axis (pixel). Default to 0
* @exception tmt_img
*/
--->
<cffunction name="bufferedCrop" access="private" output="true" hint="Create a buffered subimage, defined by a specified rectangular region, out of buffered image">
<cfargument name="imgBuffer" required="true" hint="Java buffered image">
<cfargument name="areaWidth" type="numeric" required="false" default="100" hint="Width of the specified rectangular region. Default to 100">
<cfargument name="areaHeight" type="numeric" required="false" default="100" hint="Height of the specified rectangular region. Default to 100">
<cfargument name="x" type="numeric" required="false" default="0" hint="Starting coordinate in the x axis (pixel). Default to 0">
<cfargument name="y" type="numeric" required="false" default="0" hint="Starting coordinate in the y axis (pixel). Default to 0">
<cfscript>
// Read image dimensions
var imgW = arguments.imgBuffer.getWidth();
var imgH = arguments.imgBuffer.getHeight();
// Create image output
var outBufferedImg = createJavaImg(imgW, imgH);
// Initialize a Graphics2D object
var jGraphics2D = getJavaGraphics2D(outBufferedImg);
// Perform the crop operation
var jCrop = outBufferedImg.getSubimage(JavaCast("int", arguments.x),JavaCast("int", arguments.y), JavaCast("int", arguments.areaWidth), JavaCast("int", arguments.areaHeight));
</cfscript>
<cftry>
<cfscript>
// Draw the cropped image
jGraphics2D.drawImage(arguments.imgBuffer, JavaCast("int", 0), JavaCast("int", 0), createJavaObserver());
jGraphics2D.dispose();
</cfscript>
<cfcatch type="any">
<cfthrow message="Failed to crop image #cfcatch.Message#" type="tmt_img">
</cfcatch>
</cftry>
<cfreturn jCrop>
</cffunction>

<!--- Dimensions related methods --->

<!---
/**
* Returns a structure containing the dimensions (pixels) of a jpg, png or gif image file. Keys are: width and height
* @access public
* @output suppressed
* @param imgPath (string) Required. Image path, either local or absolute
* @exception tmt_img
* @return struct
*/
--->
<cffunction name="getDimensions" access="public" output="false" returntype="struct" hint="Returns a structure containing the dimensions (pixels) of a jpg, png or gif image file. Keys are: width and height">
<cfargument name="imgPath" type="string" required="true" hint="Image path, either local or absolute">
<cfscript>
var imgStruct = StructNew();
var jFile = urlToJavaFile(arguments.imgPath, true);
var jBufferedImg = javaFileToJavaImg(jFile);
</cfscript>
<cftry>
<!--- Get the info and store them into the structure --->
<cfset imgStruct.width=jBufferedImg.getWidth()>
<cfset imgStruct.height=jBufferedImg.getHeight()>
<cfcatch type="any">
<cfthrow message="Failed to read image dimensions. The component can read only jpg, gif and png files" type="tmt_img">
</cfcatch>
</cftry>
<cfreturn Duplicate(imgStruct)>
</cffunction>

<!---
/**
* Returns the width (pixels) of a jpg, png or gif image file
* @access public
* @output suppressed
* @param imgPath (string) Required. Image path, either local or absolute
* @return numeric
*/
--->
<cffunction name="getWidth" access="public" output="false" returntype="numeric" hint="Returns the width (pixels) of a jpg, png or gif image file">
<cfargument name="imgPath" type="string" required="true" hint="Image path, either local or absolute">
<cfreturn getDimensions(imgPath).width>
</cffunction>

<!---
/**
* Returns the height (pixels) of a jpg, png or gif image file
* @access public
* @output suppressed
* @param imgPath (string) Required. Image path, either local or absolute
* @return numeric
*/
--->
<cffunction name="getHeight" access="public" output="false" returntype="numeric" hint="Returns the height (pixels) of a jpg, png or gif image file">
<cfargument name="imgPath" type="string" required="true" hint="Image path, either local or absolute">
<cfreturn getDimensions(imgPath).height>
</cffunction>

<!---
/**
* Returns the size (KB) of a jpg, png or gif image file
* @access public
* @output suppressed
* @param imgPath (string) Required. Image path, either local or absolute
* @return numeric
*/
--->
<cffunction name="getSize" access="public" output="false" returntype="numeric" hint="Returns the size (KB) of a jpg, png or gif image file">
<cfargument name="imgPath" type="string" required="true" hint="Image path, either local or absolute">
<cfreturn urlToJavaFile(arguments.imgPath, true).length()/1000>
</cffunction>

<!--- Private utility methods --->

<!---
/**
* Adds a prefix to a filename
* @access private
* @output enabled
* @param pathToPrefix (string) Required. File path, either local or absolute
* @param prefixString (string) Optional. Default to thumb_. String used as prefix
* @return string
*/
--->
<cffunction name="addPrefix" access="private" output="true" returntype="string" hint="Adds a prefix to a filename">
<cfargument name="pathToPrefix" type="string" required="yes" hint="File path, either local or absolute">
<cfargument name="prefixString" type="string" required="no" default="thumb_" hint="String used as prefix">
<cfscript>
var prefixedPath = "";
var dirPath = GetDirectoryFromPath(arguments.pathToPrefix);
var filename=GetFileFromPath(arguments.pathToPrefix);
// If the directory is the current one, skip it
if((dirPath EQ "/"wink OR (dirPath EQ "\"wink){
dirPath = "";
}
return dirPath & arguments.prefixString & filename;
</cfscript>
</cffunction>

<!---
/**
* Create a java.awt.image.BufferedImage object
* @access private
* @output suppressed
* @param imgWidth (numeric) Required. Default to 100. Image width. Default to 100
* @param imgHeight (numeric) Required. Default to 100. Image height. Default to 100
*/
--->
<cffunction name="createJavaImg" access="private" output="false" hint="Create a java.awt.image.BufferedImage object">
<cfargument name="imgWidth" type="numeric" required="yes" default="100" hint="Image width. Default to 100">
<cfargument name="imgHeight" type="numeric" required="yes" default="100" hint="Image height. Default to 100">
<cfreturn createObject("java","java.awt.image.BufferedImage"wink.init(JavaCast("int", arguments.imgWidth), JavaCast("int", arguments.imgHeight), JavaCast("int", 1))>
</cffunction>

<!---
/**
* Create a dummy Java ImageObserver object. Since CFML can't create Java nulls, we use this hack
* @access private
* @output suppressed
*/
--->
<cffunction name="createJavaObserver" access="private" output="false" hint="Create a dummy Java ImageObserver object. Since CFML can't create Java nulls, we use this hack">
<cfreturn createObject("java","java.awt.Button"wink.init()>
</cffunction>

<!---
/**
* Turn any system path, either local or absolute, into a fully qualified one
* @access private
* @output suppressed
* @param path (string) Required. Abstract pathname
* @return string
*/
--->
<cffunction name="getAbsolutePath" access="private" output="false" returntype="string" hint="Turn any system path, either local or absolute, into a fully qualified one">
<cfargument name="path" type="string" required="true" hint="Abstract pathname">
<cfscript>
var jFile = createObject("java","java.io.File"wink.init(arguments.path);
if(jFile.isAbsolute()){
return arguments.path;
}
else{
return ExpandPath(arguments.path);
}
</cfscript>
</cffunction>

<!---
/**
* Get a Java Graphics2D object out of a BufferedImage using the current settings
* @access private
* @output suppressed
* @param imgBuffer (string) Required. Java buffered image
*/
--->
<cffunction name="getJavaGraphics2D" access="private" output="false" hint="Get a Java Graphics2D object out of a BufferedImage using the current settings">
<cfargument name="imgBuffer" type="string" required="true" hint="Java buffered image">
<cfscript>
// Create the Graphics2D object
var jGraphics2D = arguments.imgBuffer.createGraphics();
// Set interpolation type
jGraphics2D.setRenderingHint(variables.jHints.KEY_INTERPOLATION, variables.interpolationType);
// Set rendering algorithms
jGraphics2D.setRenderingHint(variables.jHints.KEY_RENDERING, variables.renderQuality);
jGraphics2D.setRenderingHint(variables.jHints.KEY_COLOR_RENDERING, variables.colorRendering);
jGraphics2D.setRenderingHint(variables.jHints.KEY_DITHERING, variables.dithering);
jGraphics2D.setRenderingHint(variables.jHints.KEY_ANTIALIASING, variables.antialiasing);
return jGraphics2D;
</cfscript>
</cffunction>

<!---
/**
* Turn a file path into a java.io.File object
* @access private
* @output suppressed
* @param imgPath (string) Required. File path, either local or absolute
* @param checkExist (boolean) Optional. Default to false. Throw an exception if the file doesn't exists
* @exception tmt_img
*/
--->
<cffunction name="urlToJavaFile" access="private" output="false" hint="Turn a file path into a java.io.File object">
<cfargument name="imgPath" type="string" required="true" hint="File path, either local or absolute">
<cfargument name="checkExist" type="boolean" required="no" default="false" hint="Throw an exception if the file doesn't exists">
<cfset var absolutePath=getAbsolutePath(arguments.imgPath)>
<!--- Validate file existance --->
<cfif arguments.checkExist AND (NOT FileExists(absolutePath))>
<cfthrow message="#absolutePath# does not exist" type="tmt_img">
</cfif>
<cfreturn createObject("java","java.io.File"wink.init(absolutePath)>
</cffunction>

<!---
/**
* Turn a java.io.File object into a javax.imageio.ImageIO object
* @access private
* @output suppressed
* @param jFile Required. Java File object
*/
--->
<cffunction name="javaFileToJavaImg" access="private" output="false" hint="Turn a java.io.File object into a javax.imageio.ImageIO object">
<cfargument name="jFile" required="yes" hint="Java File object">
<cfreturn createObject("java","javax.imageio.ImageIO"wink.read(arguments.jFile)>
</cffunction>

<!---
/**
* Save a Java image to disk
* @access private
* @output suppressed
* @param imgBuffer Required. Java buffered image (source)
* @param imgBufferOut Required. Java buffered image (destination)
* @exception tmt_img
* @return boolean
*/
--->
<cffunction name="saveJavaImg" access="private" output="false" returntype="boolean" hint="Save a Java image to disk">
<cfargument name="imgBuffer" required="yes" hint="Java buffered image (source)">
<cfargument name="imgBufferOut" required="yes" hint="Java buffered image (destination)">
<cfset var fileSaved=true>
<cftry>
<cfset fileSaved=createObject("java","javax.imageio.ImageIO"wink.write(arguments.imgBuffer, variables.imgType, arguments.imgBufferOut)>
<cfcatch type="any">
<!--- Failed to save the file. Depending on the current settings, we either throw an exception or return false --->
<cfif variables.throwOnSave>
<cfthrow message="Failed to save image" type="tmt_img">
</cfif>
<cfset fileSaved=false>
</cfcatch>
</cftry>
<cfreturn fileSaved>
</cffunction>

</cfcomponent>
Re: What's Your Favourite Coldfusion Tag by boraddo(m): 2:02pm On Feb 16, 2007
naijafan, help me tell them o!
more codes.  below is code to create a CAPTCHA image, 


<cffunction name="writeToStream" hint="Writes to a outputStream" access="private" returntype="void" output="false">
<cfargument name="outputStream" hint="Gimme a java.io.OutputStream" type="any" required="Yes">
<cfargument name="text" hint="The text to display" type="string" required="Yes">
<cfargument name="width" hint="The width of the image" type="numeric" required="true">
<cfargument name="height" hint="The height of the image" type="numeric" required="true">
<cfargument name="fontsize" hint="The font size the text" type="numeric" required="true">
<cfargument name="LeftOffset" hint="The number of pixels of padding to put to the left of the text" type="numeric" required="true">
<cfargument name="TopOffset" hint="The number of pixels of padding to put to the top of the text" type="numeric" required="true">
<cfargument name="shearXRange" hint="The amount to shear the font on the X axis" type="numeric" required="true">
<cfargument name="shearYRange" hint="The amount to shear the font on the Y axis" type="numeric" required="true">

<cfscript>
/* variables */
var counter = 0; var characters = 0; var top = 0;
var len = 0; var size = 0; var left = 0;
var response = 0; var char = 0; var encoder = 0;
var encoderParam = 0;

/* utils */
var staticArrays = createObject("java", "java.util.Arrays"wink;
var staticCollections = createObject("java", "java.util.Collections"wink;


/* prep image */
var dimension = createObject("java", "java.awt.Dimension"wink.init(width, height);
var imageType = createObject("java", "java.awt.image.BufferedImage"wink.TYPE_INT_RGB;
var bufferedImage = createObject("java", "java.awt.image.BufferedImage"wink.init(JavaCast("int", dimension.getWidth()), JavaCast("int", dimension.getHeight()), imageType);
var graphics = bufferedImage.createGraphics();

/* get the fonts */
var allFonts = staticArrays.asList(createObject("java", "java.awt.GraphicsEnvironment"wink.getLocalGraphicsEnvironment().getAllFonts());


/* drawing graphics here */

/* background */
var startColor = createRandomLightGreyScaleColor();
var endColor = createRandomLightGreyScaleColor();

var gradientPaint = createObject("java", "java.awt.GradientPaint"wink.init(getRandomPointOnBorder(dimension),
startColor,
getRandomPointOnBorder(dimension),
endColor);

var background = createObject("java", "java.awt.Rectangle"wink.init(dimension);

graphics.setPaint(gradientPaint);
graphics.fill(background);

/* draw some lines */
len = randRange(10, 20);
for(counter = 1; counter lte len; counter = counter + 1)
{
drawRandomLine(graphics, dimension);
}

/* draw the text in random font characters */
characters = text.toCharArray();
len = ArrayLen(characters);

size = fontsize;
top = topOffset;
left = Leftoffset;

staticCollections.shuffle(allFonts);
for(counter = 1; counter lte len; counter = counter + 1)
{
char = characters[counter];
setNewFont(graphics, allFonts, size, arguments.shearXRange, arguments.shearYRange);
graphics.setColor(createRandomDarkGreyScaleColor());

//if cannot display, find a font that can
while(NOT graphics.getFont().canDisplay(char))
{
setNewFont(graphics, allFonts, size, arguments.shearXRange, arguments.shearYRange);
}
graphics.drawString(JavaCast("string", char), JavaCast("int", left), JavaCast("int", top));
left = left + (2 * graphics.getFontMetrics().charWidth(char));
}

/* draw a few more lines */

len = randRange(2, round(max(min(width, height) / 20, 3))); //draw more lines the bigger it is.
for(counter = 1; counter lte len; counter = counter + 1)
{
drawRandomLine(graphics, dimension);
}


encoder = createObject("java", "com.sun.image.codec.jpeg.JPEGCodec"wink.createJPEGEncoder(arguments.outputstream);
encoderParam = encoder.getDefaultJPEGEncodeParam(bufferedImage);
encoderParam.setQuality(JavaCast("float", 0.80), false);
encoder.setJPEGEncodeParam(encoderParam);
encoder.encode(bufferedImage);

</cfscript>

</cffunction>
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 2:10pm On Feb 16, 2007
I'm challenging smartsoft and/or sbucareer to please write the equivalent of the above codes in PHP.
Re: What's Your Favourite Coldfusion Tag by boraddo(m): 2:13pm On Feb 16, 2007
well, they dont even have to write it, let them just copy and paste.
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 2:15pm On Feb 16, 2007
oh yeah, true. bet they'll have to use a very lengthy file with about 10 other includes or something. grin
Re: What's Your Favourite Coldfusion Tag by breeolan(f): 2:19pm On Feb 16, 2007
u guys should chill 4 'em, if CF sucks, wat doesnt?, pascal, fortran,basic,cobaol, C'mon how much of an hater can you be, if you're not into CF, you better be into Java or ur stale!!!!!
Re: What's Your Favourite Coldfusion Tag by penyng: 9:25pm On Feb 16, 2007
@sbucareer

u must always check for fact before posting
macromedia does not exit again.
what we have now is ADOBE CORPORATION
SO, forget about the media there.

I feel that coldfusion is a good programming language
and i have decided to stick with it
Re: What's Your Favourite Coldfusion Tag by sbucareer(f): 5:52am On Feb 17, 2007

feel that coldfusion is a good programming language
and i have decided to stick with it

Good luck to you and more CF to your elbow. In my last post, I made no reference to any source, I said it was my own opinion This is a free forum everyone is entitled to their opinion(s)

It is not just writing script language and providing a good presentation for the web. It is how interoperability, cohesive, [url=http://www.google.co.uk/search?hl=en&q=define%3A+abstraction&meta=]abstaction[/url] and how easily you can decommission the system after lengthy life period and how legacy it would still remain to the new generation language that will be in place in the next few years ahead.

In my own opinion, I would still say to throw CF away to forget it ever existed. No personal feelings. Any frivolous language have no parody to leading software vendor. CF is not contingent to programmers even the people that program the system but it is prefer.

Advocacy for any language is not my prerogative, although my support for any language both script and plaftform development would have the above mentioned mechanism. I would not even mention OOP.

When people see a language with Object encapsulation their mind quickly jump to conclusion that the program is OOP compactible. Can CF persist it Object? How many company including Macromedia is developing Object Database, mind you we are passing the era of relational database. We are entering Object database. Where does CF stand on this?
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 8:22am On Feb 17, 2007
wetin sbucareer dey talk?!

sbucareer:


It is not just writing script language and providing a good presentation for the web. It is how interoperability, cohesive, [url=http://www.google.co.uk/search?hl=en&q=define%3A+abstraction&meta=]abstaction[/url] and how easily you can decommission the system after lengthy life period and how legacy it would still remain to the new generation language that will be in place in the next few years ahead.


what exactly is your point here? mind you, coldfusion takes the best of both worlds, tagbased coding and java-like coding. The world is going tagbased my brother, with XML and its variants appearing here and there. Yahoo widgets and Microsoft gadgets are written in tagbased xml-like code. The new introduction by Macromedia, now adopted by Adobe; Flex, uses a language called MXML and Action Script 3 which is fully object oriented. Databases are moving from stupid proprietery formats to XML based formats, so what are we saying here? The world is going tag based and ColdFusion is ahead of others in this race!

sbucareer:


In my own opinion, I would still say to throw CF away to forget it ever existed. No personal feelings. Any frivolous language have no parody to leading software vendor. CF is not contingent to programmers even the people that program the system but it is prefer.

Advocacy for any language is not my prerogative, although my support for any language both script and plaftform development would have the above mentioned mechanism. I would not even mention OOP.

When people see a language with Object encapsulation their mind quickly jump to conclusion that the program is OOP compactible. Can CF persist it Object? How many company including Macromedia is developing Object Database, mind you we are passing the era of relational database. We are entering Object database. Where does CF stand on this?


Could you please make yourself more clear in the last paragraph? Or probably get someone to type out your thoughts if you arent that much of a fan of English language.
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 8:45am On Feb 17, 2007
1. Did you hear that 75 of the Fortune 100 companies use ColdFusion?

2. MySpace.com is based on ColdFusion

3. Google Finance is based on Flex (The Adobe language i told you about earlier)

4. Yahoo! Maps is based on Flex

5. Forget the cost of the application server, ColdFusion shared hosting is almost as cheap as PHP.

6. For Enterprise Level deployment, PHP from Zend costs more than ColdFusion from Adobe. (imagine that!)
Re: What's Your Favourite Coldfusion Tag by sbucareer(f): 8:04pm On Feb 17, 2007

I think I would need to employ you to prove read my English. Just drop me an email with your salary range. XML is not a programming language or a script language it is a [url=http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=deskbar&q=define%3A+XML]Markup language[/url]

It is used on the web to exchange information between systems. Vendor has used it full potential as information exchange to exchanging objectS between applications. Hence, today XML is used as a configuration script or to couple systems together.

I do not want to know your ambitions with CF and how Abode is creating more platform for Flex technology or if fortune 100 companies are using CF. These are trading platforms, the need for data exchange is great and if using CF to run their entire system is achievable, is up to them.

I, as a responsible developer will not encourage any body to couple their system (Web Server) to CF whether data exchange is their priority or not.

If my logic about CF annoys you, prove to us that CF has come of age, don't paste snazzy codes and expect me to be accommodating. That is how the Europeans trick us into colonization (Oka nma na anya).

I don't like CF period, and will never do. When such a time comes when CF has come of age and start to hold global conferences to promote their platform then I can attend to one of their seminars and ask them tough questions in relation to web server, legacy system and system migration and termination, and where CF stand on these?.

Like I said good luck to you and more CF to your elbow. Regarding my English language, I am seriously looking for a teacher, send me your [email=valentine.obih@gmail.com?sbject=English teacher]CV[/email] No heart feelings, just don't like CF. You have the same right to like CF.
Re: What's Your Favourite Coldfusion Tag by sbucareer(f): 8:16pm On Feb 17, 2007

In short, what is the Road Map of CF and Adobe Flex 2? Later on someone will come up with the idea the Ajax and Ruby on Rails are the language for the future, excuse me?

I am still waiting for a language that will supersede Java and .NET. Till then all the rest are just followers.

Just don't believe me, look at their market capitalization and the P/e and stock indexes. This is how you measure success.
Re: What's Your Favourite Coldfusion Tag by naijafan(m): 7:10pm On Feb 19, 2007
1. Nah, I've got a well paying job already wink. Sorry to dissapoint you but hope you find someone as good as i am. grin

2. I never said XML was a programming language. You might consider emplying an English reader too cheesy (just kiddin'). I was just talking about tag-based XML-like coding and made reference to Yahoo widgets and Microsoft Gadgets.

3. Why mix the Fortune 100 companies with trading platforms? Maybe I didnt get you tho.

4. Be sincere. You loved those codes tongue

5. Ever heard of Adobe MAX? Well, Adobe MAX 2006 was held around October last year. You might consider attending Adobe MAX 2007 and have your questions answered. I bet they'd been answered before then.

6. Ever heard of the Apollo framework? Its debutting very soon. Flash player 9 adoption all over the world across platforms superceded Java and .Net. Funny enough, its the runtime required to run Flex applications. Dont you sense anything there?

(1) (Reply)

Best Payment Provider / Gateway For Marketplace Websites In Africa? / Help On Javascript! / Please What Really Is Object Oriented Programming.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 146
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.