Created
July 20, 2011 13:50
-
-
Save boltz/1094983 to your computer and use it in GitHub Desktop.
Turn Text into a vertical image
This file contains 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
<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