Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion, SYS-CON MEDIA

ColdFusion: Article

CFImage Functionality is Just Awesome!

Integration into Tag and Scripting Language is a Welcome Development

Finally, ColdFusion 8 has incorporated image manipulation directly into the ColdFusion tag and scripting language. No more are we, as developers, chained to third-party products.

These products, while excellent in quality, just mean adding one more level of complexity to any application that requires server-side image manipulation. Now, with CFImage and an abundance of image-related functions, ColdFusion has done to image manipulation what it has done to almost every other aspect of Web applications development - it has made it simple.

Due to the wide array of image functionality in ColdFusion 8, I am going to try and break this tutorial up into several small and manageable parts. The first part will cover basic reading and writing of images using CFImage and the related image manipulation functions. But, before we get into that, let's just quickly touch upon these new features as a whole.

ColdFusion 8 has given us CFImage. CFImage provides us with tag-based access to only a small subset of the image functionality including:

  • Retrieving information about an image
  • Reading an image into memory
  • Resizing an image
  • Rotating an image
  • Adding a border to an image
  • Converting an image from one file format to another
  • Creating a CAPTCHA image
  • Writing an image to a file
  • Writing an image to the browser

    In addition to the CFImage tag, ColdFusion has introduced dozens of new image manipulation functions including:

     

  • ImageAddBorder()
  • ImageBlur()
  • ImageClearRect()
  • ImageCopy()
  • ImageCrop()
  • ImageDrawArc()
  • ImageDrawBeveledRect()
  • ImageDrawCubicCurve()
  • ImageDrawLine()
  • ImageDrawLines()
  • ImageDrawOval()
  • ImageDrawPoint()
  • ImageDrawQuadraticCurve()
  • ImageDrawRect()
  • ImageGetEXIFTag()
  • ImageGetHeight()
  • ImageGetIPTCTag()
  • ImageGetWidth()
  • ImageGrayscale()
  • ImageInfo()
  • ImageNegative()
  • ImageNew()
  • ImageOverlay()
  • ImagePaste()
  • ImageRead()
  • ImageReadBase64()
  • ImageResize()
  • ImageRotate()
  • ImageRotateDrawingAxis()
  • ImageScaleToFit()
  • ImageSetAntialiasing()

The ColdFusion 8 CFImage tag and the image-related functions all deal with a new ColdFusion object:

coldfusion.image.Image

Most of you are not going to care about this one all that much, but for those of you who are interested in the underlying Java methods of the coldfusion.image.Image object, I have listed them below (skip past this if you have no idea what I'm talking about). Please note that any underlying methods of the actual Java/ColdFusion objects are found by gathering object metadata and through reflection; none of these methods are documented or officially supported. If you choose to use them, you do so at your own risk and discretion.

  • addBorder( int, java.lang.String, java.lang.String ) - returns: void
  • blur( int ) - returns: void
  • brighten() - returns: void
  • clearRect( int, int, int, int ) - returns: void
  • copyArea( int, int, int, int ) - returns: coldfusion.image.Image
  • copyArea( int, int, int, int, int, int ) - returns: coldfusion.image.Image
  • crop( float, float, float, float ) - returns: void
  • draw3DRect( int, int, int, int, boolean, boolean ) - returns: void
  • drawArc( int, int, int, int, int, int, boolean ) - returns: void
  • drawCubicCurve( double, double, double, double, double, double, double, double ) - returns: void
  • drawLine( int, int, int, int ) - returns: void
  • drawLines( [I, [I, boolean, boolean ) - returns: void
  • drawOval( int, int, int, int, boolean ) - returns: void
  • drawPoint( int, int ) - returns: void
  • drawQuadraticCurve( double, double, double, double, double, double ) - returns: void
  • drawRect( int, int, int, int, boolean ) - returns: void
  • drawRoundRect( int, int, int, int, int, int, boolean ) - returns: void
  • drawString( java.lang.String, int, int, coldfusion.runtime.Struct ) - returns: void
  • flip( java.lang.String ) - returns: void
  • getBase64String( java.lang.String ) - returns: java.lang.String
  • getClass() - returns: java.lang.Class
  • getColor( java.lang.String ) - returns: java.awt.Color
  • getCurrentGraphics() - returns: java.awt.Graphics2D
  • getCurrentImage() - returns: java.awt.image.BufferedImage
  • getExifMetadata( javax.servlet.jsp.PageContext )- returns: coldfusion.runtime.Struct
  • getExifTag( java.lang.String, javax.servlet.jsp.PageContext ) - returns: java.lang.String
  • getHeight() - returns: int
  • getImageBytes( java.lang.String ) - returns: [B
  • getIptcMetadata( javax.servlet.jsp.PageContext ) - returns: coldfusion.runtime.Struct
  • getIptcTag( java.lang.String, javax.servlet.jsp.PageContext ) - returns: java.lang.String
  • getSource() - returns: java.lang.String
  • getWidth() - returns: int
  • grayscale() - returns: void
  • info() - returns: coldfusion.runtime.Struct
  • initializeMetadata( javax.servlet.jsp.PageContext ) - returns: void
  • invert() - returns: void
  • overlay( coldfusion.image.Image ) - returns: void
  • paste( coldfusion.image.Image, int, int ) - returns: void
  • readBase64( java.lang.String ) - returns: void
  • resize( java.lang.String, java.lang.String, java.lang.String ) - returns: void
  • resize( java.lang.String, java.lang.String, java.lang.String, double ) - returns: void
  • rotate( float, float, float, java.lang.String ) - returns: void
  • rotateAxis( double ) - returns: void
  • rotateAxis( double, double, double ) - returns: void
  • scaleToFit( int ) - returns: void
  • scaleToFit( java.lang.String, java.lang.String, java.lang.String ) - returns: void
  • scaleToFit( java.lang.String, java.lang.String, java.lang.String, double ) - returns: void
  • setAntiAliasing( java.lang.String ) - returns: void
  • setBackground( java.lang.String ) - returns: void
  • setColor( java.lang.String ) - returns: void
  • setDrawingStroke( coldfusion.runtime.Struct ) - returns: void
  • setDrawingStroke( float, int, int, float, [F, float ) - returns: void
  • setRenderingHint( java.awt.RenderingHints$Key, java.lang.Object ) - returns: void
  • setTranparency( double ) - returns: void
  • setXorMode( java.lang.String ) - returns: void
  • sharpen( float ) - returns: void
  • sharpenEdge() - returns: void
  • shear( float, java.lang.String, java.lang.String ) - returns: void
  • shearAxis( double, double ) - returns: void
  • translate( int, int, java.lang.String ) - returns: void
  • translateAxis( int, int ) - returns: void
  • write( java.lang.String, float ) - returns: void
  • writeBase64( java.lang.String, java.lang.String, boolean ) - returns: void

More Stories By Ben Nadel

Ben Nadel has worked with ColdFusion for eight years and is a super ColdFusion enthusiast. He blogs regularly about all aspects of Web development on his personal site, http://www.bennadel.com, and does his best to give back to the ColdFusion community through online code demos and his "Ask Ben" blog posts. He is also a Certified Advanced ColdFusion MX7 developer and is one of the lead programmers at Nylon Technology.

Comments (3) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Michael 07/12/08 01:43:25 AM EDT

The noisy ad is beyond annoying.

Mike Ritchie 08/01/07 06:08:54 PM EDT

I wonder if the CF team consulted with the developer of ImageCFC? It also was basically a wrapper for the underlying Java image functionality. Either way, this looks like an exceptionally useful tool. Do you need to instantiate the object using cfimage? Or is it possible to manipulate an image completely within cfscript?

Sanjeev 07/15/07 10:07:34 PM EDT

rename the CodFusion as ColdFusion !

@ThingsExpo Stories
SYS-CON Events announced today that DatacenterDynamics has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. DatacenterDynamics is a brand of DCD Group, a global B2B media and publishing company that develops products to help senior professionals in the world's most ICT dependent organizations make risk-based infrastructure and capacity decisions.
SYS-CON Events announced today TMCnet has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Technology Marketing Corporation (TMC) is the world's leading business-to-business and integrated marketing media company, servicing niche markets within the com...
The IoT has the potential to create a renaissance of manufacturing in the US and elsewhere. In his session at 18th Cloud Expo, Florent Solt, CTO and chief architect of Netvibes, will discuss how the expected exponential increase in the amount of data that will be processed, transported, stored, and accessed means there will be a huge demand for smart technologies to deliver it. Florent Solt is the CTO and chief architect of Netvibes. Prior to joining Netvibes in 2007, he co-founded Rift Technol...
Join IBM June 8 at 18th Cloud Expo at the Javits Center in New York City, NY, and learn how to innovate like a startup and scale for the enterprise. You need to deliver quality applications faster and cheaper, attract and retain customers with an engaging experience across devices, and seamlessly integrate your enterprise systems. And you can't take 12 months to do it.
This is not a small hotel event. It is also not a big vendor party where politicians and entertainers are more important than real content. This is Cloud Expo, the world's longest-running conference and exhibition focused on Cloud Computing and all that it entails. If you want serious presentations and valuable insight about Cloud Computing for three straight days, then register now for Cloud Expo.
IoT device adoption is growing at staggering rates, and with it comes opportunity for developers to meet consumer demand for an ever more connected world. Wireless communication is the key part of the encompassing components of any IoT device. Wireless connectivity enhances the device utility at the expense of ease of use and deployment challenges. Since connectivity is fundamental for IoT device development, engineers must understand how to overcome the hurdles inherent in incorporating multipl...
Machine Learning helps make complex systems more efficient. By applying advanced Machine Learning techniques such as Cognitive Fingerprinting, wind project operators can utilize these tools to learn from collected data, detect regular patterns, and optimize their own operations. In his session at 18th Cloud Expo, Stuart Gillen, Director of Business Development at SparkCognition, will discuss how research has demonstrated the value of Machine Learning in delivering next generation analytics to im...
Manufacturers are embracing the Industrial Internet the same way consumers are leveraging Fitbits – to improve overall health and wellness. Both can provide consistent measurement, visibility, and suggest performance improvements customized to help reach goals. Fitbit users can view real-time data and make adjustments to increase their activity. In his session at @ThingsExpo, Mark Bernardo Professional Services Leader, Americas, at GE Digital, will discuss how leveraging the Industrial Interne...
The paradigm has shifted. A Gartner survey shows that 43% of organizations are using or plan to implement the Internet of Things in 2016. However, not just a handful of companies are still using the old-style ad-hoc trial-and-error ways, unaware of the critical barriers, paint points, traps, and hidden roadblocks. How can you become a winner? In his session at @ThingsExpo, Tony Shan will present a methodical approach to guide the holistic adoption and enablement of IoT implementations. This ov...
SYS-CON Events announced today that Stratoscale, the software company developing the next generation data center operating system, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Stratoscale is revolutionizing the data center with a zero-to-cloud-in-minutes solution. With Stratoscale’s hardware-agnostic, Software Defined Data Center (SDDC) solution to store everything, run anything and scale everywhere...
Angular 2 is a complete re-write of the popular framework AngularJS. Programming in Angular 2 is greatly simplified – now it's a component-based well-performing framework. This immersive one-day workshop at 18th Cloud Expo, led by Yakov Fain, a Java Champion and a co-founder of the IT consultancy Farata Systems and the product company SuranceBay, will provide you with everything you wanted to know about Angular 2.
Digital payments using wearable devices such as smart watches, fitness trackers, and payment wristbands are an increasing area of focus for industry participants, and consumer acceptance from early trials and deployments has encouraged some of the biggest names in technology and banking to continue their push to drive growth in this nascent market. Wearable payment systems may utilize near field communication (NFC), radio frequency identification (RFID), or quick response (QR) codes and barcodes...
SYS-CON Events announced today that Men & Mice, the leading global provider of DNS, DHCP and IP address management overlay solutions, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. The Men & Mice Suite overlay solution is already known for its powerful application in heterogeneous operating environments, enabling enterprises to scale without fuss. Building on a solid range of diverse platform support,...
You deployed your app with the Bluemix PaaS and it's gaining some serious traction, so it's time to make some tweaks. Did you design your application in a way that it can scale in the cloud? Were you even thinking about the cloud when you built the app? If not, chances are your app is going to break. Check out this webcast to learn various techniques for designing applications that will scale successfully in Bluemix, for the confidence you need to take your apps to the next level and beyond.
The increasing popularity of the Internet of Things necessitates that our physical and cognitive relationship with wearable technology will change rapidly in the near future. This advent means logging has become a thing of the past. Before, it was on us to track our own data, but now that data is automatically available. What does this mean for mHealth and the "connected" body? In her session at @ThingsExpo, Lisa Calkins, CEO and co-founder of Amadeus Consulting, will discuss the impact of wea...
Whether your IoT service is connecting cars, homes, appliances, wearable, cameras or other devices, one question hangs in the balance – how do you actually make money from this service? The ability to turn your IoT service into profit requires the ability to create a monetization strategy that is flexible, scalable and working for you in real-time. It must be a transparent, smoothly implemented strategy that all stakeholders – from customers to the board – will be able to understand and comprehe...
So, you bought into the current machine learning craze and went on to collect millions/billions of records from this promising new data source. Now, what do you do with them? Too often, the abundance of data quickly turns into an abundance of problems. How do you extract that "magic essence" from your data without falling into the common pitfalls? In her session at @ThingsExpo, Natalia Ponomareva, Software Engineer at Google, will provide tips on how to be successful in large scale machine lear...
SYS-CON Events announced today that Ericsson has been named “Gold Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. Ericsson is a world leader in the rapidly changing environment of communications technology – providing equipment, software and services to enable transformation through mobility. Some 40 percent of global mobile traffic runs through networks we have supplied. More than 1 billion subscribers around the world re...
SYS-CON Events announced today that Fusion, a leading provider of cloud services, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Fusion, a leading provider of integrated cloud solutions to small, medium and large businesses, is the industry's single source for the cloud. Fusion's advanced, proprietary cloud service platform enables the integration of leading edge solutions in the cloud, including cloud...
The IETF draft standard for M2M certificates is a security solution specifically designed for the demanding needs of IoT/M2M applications. In his session at @ThingsExpo, Brian Romansky, VP of Strategic Technology at TrustPoint Innovation, will explain how M2M certificates can efficiently enable confidentiality, integrity, and authenticity on highly constrained devices.