Whatever message this page gives is out now! Go check it out!
<cfimage source="../cfdocs/images/artgallery/jeff01.jpg" action="border" thickness="5" color="blue" destination="testMyImage.jpg" overwrite="yes"> <img src="testMyImage.jpg"> |
<!--- Create a ColdFusion image from a JPEG file. ---> <cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")> <!--- Add a 5-pixel blue border around the outside edge of the image. ---> <cfset ImageAddBorder(myImage,5,"blue")> <!--- Add a 10-pixel magenta border around the blue border. ---> <cfset ImageAddBorder(myImage,10,"magenta")> <!--- Add a 5-pixel green border around the magenta border. ---> <cfset ImageAddBorder(myImage,20,"green")> <!--- Write the ColdFusion image to a file. ---> <cfset ImageWrite(myImage,"testMyImage.jpg")> <img src="testMyImage.jpg"/> |
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff03.jpg")> <cfset ImageAddBorder(myImage,20,"","wrap")> <cfset ImageWrite(myImage,"testMyImage.jpg")> <img src="testMyImage.jpg"/> |
image directly to the browser. ---> <cfimage action="captcha" fontSize="25" width="162" height="75" text="rEadMe" fonts="Verdana,Arial,Courier New,Courier"> |
<cfset tc = GetTickCount()> <!--- Set the difficulty to "high" for a higher level of text distortion. ---> <cfimage action="captcha" fontSize="15" width="180" height="50" text="rEadMe" destination="readme#tc#.png" difficulty="high"> |

<cfset myImage=ImageNew("",200,100)> <cfset ImageDrawText(myImage, "Congratulations!",10,50)> <cfimage source="#myImage#" action="write" destination="myImage.png" overwrite="yes"> <img src="myImage.png"> <!--- This example shows how to draw a text string on an existing image. ---> <cfset myImage2=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")> <cfset ImageDrawText(myImage2,"Congratulations!",10,50)> <cfimage source="#myImage2#" action="write" destination="myImage2.png" overwrite="yes"> <img src="myImage2.png"> |
<cfset attr.style="bolditalic"> <cfset attr.size=20> <cfset attr.font="verdana"> <cfset attr.underline="yes"> |
<cfset ImageDrawText(myImage,"Congratulations!",10,50,attr)> |
<cfset myImage=ImageNew("../cfdocs/images/artgallery/jeff01.jpg")> <cfset ImageSetDrawingColor(myImage,"magenta")> <cfset attr = StructNew()> <cfset attr.style="bolditalic"> <cfset attr.size=20> <cfset attr.font="verdana"> <cfset attr.underline="yes"> <cfset ImageDrawText(myImage,"Congratulations!",10,50,attr)> <cfset ImageDrawText(myImage,"Gabriella",50,125,attr)> <cfimage source="#myImage#" action="write" destination="myImage.jpg" overwrite="yes"> <img src="myImage.jpg"/> |
<cfset myImage=ImageNew("",200,200)> <!--- Draw a circle that is 100 pixels in diameter. ---> <cfset ImageDrawOval(myImage,40,20,100,100)> <!--- Draw a filled rectangle that is 40 pixels wide and 20 pixels high. ---> <cfset ImageDrawRect(myImage,70,50,40,20,true)> <!--- Draw a 100-pixel square. ---> <cfset ImageDrawRect(myImage,40,40,100,100)> <!--- Draw two lines. ---> <cfset ImageDrawLine(myImage,130,40,100,200)> <cfset ImageDrawLine(myImage,50,40,100,200)> <!--- Write the ColdFusion image to a file. ---> <cfimage source="#myImage#" action="write" destination="testMyImage.gif" overwrite="yes"> <img src="testMyImage.gif"/> |
<cfset attr=StructNew()> <cfset attr.width="4"> <cfset attr.endcaps="round"> <cfset attr.dashPattern=ArrayNew(1)> <cfset dashPattern[1]=8> <cfset dashPattern[2]=6> <cfset attr.dashArray=dashPattern> <cfset myImage=ImageNew("",200,200)> <cfset ImageDrawOval(myImage,40,20,100,100)> <!--- Set the drawing color to green for all subsequent drawing functions. ---> <cfset ImageSetDrawingColor(myImage,"green")> <cfset ImageDrawRect(myImage,70,50,40,20,true)> <!--- Apply the attribute collection to all subsequent shapes and lines in the image. ---> <cfset ImageSetDrawingStroke(myImage,attr)> <cfset ImageDrawRect(myImage,40,40,100,100)> <!--- Set the drawing color to red for all subsequent drawing functions. ---> <cfset ImageSetDrawingColor(myImage,"red")> <cfset ImageDrawLine(myImage,130,40,100,200)> <cfset ImageDrawLine(myImage,50,40,100,200)> <cfimage source="#myImage#" action="write" destination="testMyImage.gif" overwrite="yes"> <img src="testMyImage.gif"/> |
| Task | Functions and actions |
Resize an image | ImageResize function, or the resize action of the cfimage tag |
Resize images so that they fit in a defined square or rectangle and control the interpolation method | ImageScaleToFit function |
Resize an image and control the interpolation method | ImageResize function |
<cfimage source="../cfdocs/images/artgallery/jeff01.jpg" action="resize" width="100" height="100" destination="jeff01_sm.jpg"> <!--- This example shows how to specify the height and width of an image as percentages. ---> <cfimage source="../cfdocs/images/artgallery/jeff02.jpg" action="resize" width="50%" height="50%" destination="jeff02_sm.jpg"> <!--- This example shows how to specify the height of an image in pixels and its width as a percentage. Notice that this technique can distort the image. ---> <cfimage source="../cfdocs/images/artgallery/jeff03.jpg" action="resize" width="50%" height="100" destination="jeff03_sm.jpg" overwrite="yes"> |
proportionately to the new width. The height value is blank. ---> <cfset myImage=ImageNew("http://www.google.com/images/logo_sm.gif")> <cfset ImageResize(myImage,"50%","")> <!--- Save the modified image to a file. ---> <cfimage source="#myImage#" action="write" destination="test_myImage.jpeg" overwrite="yes"> <!--- Display the source image and the resized image. ---> <img src="http://www.google.com/images/logo_sm.gif"/> <img src="test_myImage.jpeg"/> |
<cfset myImage=ImageNew("../cfdocs/images/artgallery/aiden01.jpg")> <cfset ImageResize(myImage,"","200%","highPerformance", 10)> <cfimage action="writeToBrowser" source="#myImage#"> |
<cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage" action="read"> <!--- Turn on antialiasing. ---> <cfset ImageSetAntialiasing(myImage)> <cfset ImageScaleToFit(myImage,100,100,"mediumQuality")> <!--- Display the modified image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> |
wide and 100 pixels high, while maintaining the aspect ratio of the source image. ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage"> <!--- Turn on antialiasing. ---> <cfset ImageSetAntialiasing(myImage)> <cfset ImageScaleToFit(myImage,200,100)> <!--- Display the modified image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> |
maintaining the aspect ratio of the source image. The interpolation method is set to maximize performance (which reduces image quality). ---> <cfimage source="../cfdocs/images/artgallery/jeff05.jpg" name="myImage"> <!--- Turn on antialiasing. ---> <cfset ImageSetAntialiasing(myImage)> <cfset ImageScaleToFit(myImage,200,"","highestPerformance")> <!--- Display the modified image in a browser. ---> <cfimage source="#myImage#" action="writeToBrowser"> |
<!--- Create two ColdFusion images from existing JPEG files. ---> <cfimage source="../cfdocs/images/artgallery/raquel05.jpg" name="myImage"> <cfimage source="http://www.google.com/images/logo_sm.gif" name="myImage2"> <cfimage source="#myImage#" action="write" destination="logo.jpg" overwrite="yes"> <cfset ImageSetDrawingTransparency(myImage,50)> <!--- Paste myImage2 on myImage at the coordinates (0,0). ---> <cfset ImagePaste(myImage,myImage2,0,0)> <!--- Write the result to a file. ---> <cfimage source="#myImage#" destination="watermark.jpg" action="write" overwrite="yes"> <!--- Display the result. ---> <img src="watermark.jpg"/> |
<cfset myImage=ImageNew("../cfdocs/images/artgallery/raquel05.jpg")> <!--- Scale the image to fit in a 200-pixel square, maintaining the aspect ratio of the source image. ---> <cfset ImageScaleToFit(myImage,200,200)> <!--- Set the drawing transparency to 75%. ---> <cfset ImageSetDrawingTransparency(myImage,75)> <!--- Create a ColdFusion image from scratch. ---> <cfset textImage=ImageNew("",150,140)> <!--- Set the drawing color to white. ---> <cfset ImageSetDrawingColor(textImage,"white")> <!--- Create a collection of text attributes. ---> <cfset attr=StructNew()> <cfset attr.size=40> <cfset attr.style="bold"> <cfset attr.font="Arial"> <!--- Turn on antialiasing. ---> <cfset ImageSetAntialiasing(textImage)> <!--- Draw the text string "PROOF" on the ColdFusion image. Apply the text attributes that you specified. ---> <cfset ImageDrawText(textImage,"PROOF",1,75,attr)> <!--- Rotate the text image by 30 degrees. ---> <cfset ImageRotate(textImage,30)> <!--- Scale the image to fit in a 200-pixel square, maintaining the aspect ratio of the source image. ---> <cfset ImageScaleToFit(textImage,200,200)> <!--- Paste the text image onto myImage. ---> <cfset ImagePaste(myImage,textImage,0,0)> <!--- Write the combined image to a file. ---> <cfimage source="#myImage#" action="write" destination="test_watermark.jpg" overwrite="yes"> <!--- Display the image. ---> <img src="test_watermark.jpg"/> |
| watermark. ---> <!--- Use the ImageNew function to create a ColdFusion image that is 201x201 pixels. ---> <cfset myImage=ImageNew("",201,201)> <!--- Set the drawing transparency of the image to 30%. ---> <cfset ImageSetDrawingTransparency(myImage,30)> <!--- Set the drawing color to red. ---> <cfset ImageSetDrawingColor(myImage,"red")> <!--- Create an attribute collection that sets the line width to ten pixels. ---> <cfset attr=StructNew()> <cfset attr.width = 10> <!--- Apply the attribute collection to the ImageSetDrawingStroke function. ---> <cfset ImageSetDrawingStroke(myImage,attr)> <!--- Draw a diagonal line starting at (40,40) and ending at (165,165) on myImage. The drawing attributes you specified are applied to the line. ---> <cfset ImageDrawLine(myImage,40,40,165,165)> <!--- Draw a circle starting at (5,5) and is 190 pixels high and 190 pixels wide. The drawing attributes you specified are applied to the oval. ---> <cfset ImageDrawOval(myImage,5,5,190,190)> <!--- Create a ColdFusion image from a JPEG file. ---> <cfimage source="../cfdocs/images/artgallery/raquel05.jpg" name="myImage2"> <!--- Scale the image to fit in a 200-pixel square, maintaining the aspect ratio of the source image. ---> <cfset ImageScaleToFit(myImage2,200,200)> <!--- Paste the myImage2 directly over the myImage. ---> <cfset ImagePaste(myImage,myImage2,0,0)> <!--- Save the combined image to a file. ---> <cfimage source="#myImage#" action="write" destination="test_watermark.jpg" overwrite="yes"> <!--- Display the image in a browser. ---> <img src="test_watermark.jpg"/> |