Skip to content

Instantly share code, notes, and snippets.

@boltz
Created July 20, 2011 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boltz/1094983 to your computer and use it in GitHub Desktop.
Save boltz/1094983 to your computer and use it in GitHub Desktop.
Turn Text into a vertical image
<cfcomponent>
<cffunction name="convert" access="remote" >
<cfargument name="text" type="string" require="true">
<cfargument name="width" type="numeric" required="true">
<cfargument name="height" type="numeric" required="true">
<cfargument name="font" type="string" required="true" default="Arial">
<cfargument name="fontsize" type="numeric" required="true" default="18">
<cfargument name="fontStyle" type="string" required="true" default="plain">
<!--- Build a Struct to hold the font info --->
<cfset var styleStruct = structNew()>
<cfset styleStruct.font = font>
<cfset styleStruct.size = fontsize>
<cfset styleStruct.style = fontStyle>
<!--- Create a new blank image --->
<cfset var myImage = imageNew("", width,height,"rgb", "white")>
<!--- Set the font color --->
<cfset ImageSetDrawingColor(myImage, "black")>
<!--- Here is where we turn it vertical by setting the Drawing Axis --->
<cfset imageRotateDrawingAxis(myimage, 90)>
<!--- Draw the text --->
<cfset imageDrawText(#myImage#, "#text#", 0,0,styleStruct)>
<cfimage action="writeToBrowser" source="#myImage#" >
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment