Created
March 25, 2014 00:52
-
-
Save bennadel/9753072 to your computer and use it in GitHub Desktop.
Trimming An Image Canvas With ImageUtils.cfc ColdFusion Image Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- Create the image utils object. ---> | |
<cfset objImageUtils = CreateObject( | |
"component", | |
"imageutilsroot.imageUtils" | |
).Init() | |
/> | |
<!--- Create a large, off-white canvas. ---> | |
<cfset objImage = ImageNew( | |
"", | |
300, | |
300, | |
"argb", | |
"##F5F5F5" | |
) /> | |
<!--- Set the drawing color. ---> | |
<cfset ImageSetDrawingColor( | |
objImage, | |
"##FF9900" | |
) /> | |
<!--- Draw a circle in the middle of the canvas. ---> | |
<cfset ImageDrawOval( | |
objImage, | |
100, | |
100, | |
100, | |
100, | |
"yes" | |
) /> | |
<!--- Set up our font properties. ---> | |
<cfset objFont = { | |
Size = "20", | |
Font = "Arial Black" | |
} /> | |
<!--- Draw text. ---> | |
<cfset ImageDrawText( | |
objImage, | |
"MY FIRST CIRCLE", | |
45, | |
250, | |
objFont | |
) /> | |
<p> | |
<!--- Write image to browser. ---> | |
<cfimage | |
action="writetobrowser" | |
source="#objImage#" | |
/> | |
</p> | |
<!--- Trim the canvas. ---> | |
<cfset objImage = objImageUtils.TrimCanvas( | |
objImage, | |
"##F5F5F5" | |
) /> | |
<p> | |
<!--- Write image to browser. ---> | |
<cfimage | |
action="writetobrowser" | |
source="#objImage#" | |
/> | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment