<cfimage>
Lets you resize and add labels to GIF and JPEG format images.
This tag cannot have a body.
This tag is also supported within <cfscript>
Requires Extension: Image Extension for Jakarta EE (Lucee 7+)
<cfimage
action=border|captcha|convert|writetobrowser|write|rotate|resize|read|info
angle=number
passthrough=string
color=string
destination=string
difficulty=string
fonts=any
fontSize=number
format=string
height=string
isBase64=boolean
name=string
overwrite=boolean
quality=number
source=any
structName=string
text=string
thickness=number
width=string
base64=boolean
nometadata=boolean
>
| Attribute | Description | Default |
|---|---|---|
action
string, optional
|
edit
Action to execute.
|
read |
angle
number, optional
|
edit
Angle in degrees to rotate the image. |
|
passthrough
string, optional
|
edit
HTML attributes that are not explicitly supported by cfimage. If you specify an attribute and value, they are passed to the tag "img". |
|
color
string, optional
|
edit
Border color. Hexadecimal value or supported named color. For a hexadecimal value, use the form "#xxxxxx" or "xxxxxx", where x = 0-9 or A-F; use two number signs or none. Alias: colour |
|
destination
string, optional
|
edit
Absolute or relative pathname where the image output is written. The image format is determined by the file extension. The convert and write actions require a destination attribute. The border, captcha, resize, and rotate actions require a name attribute or a destination attribute. You can specify both. If you do not enter a destination, the CAPTCHA image is placed inline in the HTML output and displayed in the web browser. |
|
difficulty
string, optional
|
edit
Level of complexity of the CAPTCHA text. Specify one of the following levels of text distortion: low, medium, high |
|
fonts
any, optional
|
edit
One or more valid fonts to use for the CAPTCHA text. Separate multiple fonts with commas. Lucee supports only the system fonts that the JDK can recognize. For example, TTF fonts in the Windows directory are supported on Windows. |
|
fontSize
number, optional
|
edit
font size of the text in the CAPTCHA image. |
|
format
string, optional
|
edit
Format of the image displayed in the browser. If you do not specify a format, the image is displayed in PNG format. |
|
height
string, optional
|
edit
Height in pixels of the image. For the resize attribute, you also can specify the height as a percentage. When you resize an image, if you specify a value for the width. |
|
isBase64
boolean, optional
|
edit
Specifies whether the source is a Base64 string |
|
name
string, optional
|
edit
Name of the image variable to create. The read action requires a name attribute. The border, resize, and rotate actions require a name attribute or a destination attribute. You can specify both. Alias: variable |
|
overwrite
boolean, optional
|
edit
If the destination file already exists, Lucee generates an error if the overwrite action is not set to yes. |
|
quality
number, optional
|
edit
Quality of the JPEG destination file. Applies only to files with an extension of JPG or JPEG. Valid values are fractions that range from 0 through 1 (the lower the number, the lower the quality). |
|
source
any, optional
|
edit
source file |
|
structName
string, optional
|
edit
Name of the structure to be created. Alias: result |
|
text
string, optional
|
edit
Text string displayed in the CAPTCHA image. Use capital letters for better readability. Do not include spaces because users cannot detect them in the resulting CAPTCHA image. |
|
thickness
number, optional
|
edit
Border thickness in pixels. The border is added to the outside edge of the source image, increasing the image area accordingly. |
|
width
string, optional
|
edit
Width in pixels of the image. |
|
base64
boolean, optional
|
edit
should action "writetobrowser" embed the source of the image as base64 encoded string, default is false. |
|
nometadata
boolean, optional
|
edit
only used for action "write", if set to true, the meta data from a source image are NOT written to the destination image. |
Examples
editTag Syntax
Image Write
<cfset newImg = imageNew("",200,200,"rgb","blue")>
<cfimage action="write" source="#newImg#" name="writeimg" destination="pathname" overwrite="true">
Image captcha
<cfimage action="captcha" text="Captcha!" difficulty="low" height="30" width="150" fontSize="18"
fonts="Comic Sans MS,Times New Roman">
Image read
<cfimage action="read" name="sourceImage" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4">
<cfdump var="#sourceImage#" />
Image Info
<cfimage action="info" structname="sourceImage" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4">
<cfdump var="#sourceImage#" />
Image convert
<cfimage action="convert" structname="sourceImage" destination="#expandpath("./lii.jpeg")#"
source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4">
<cfimage action="writeToBrowser" source="#expandpath("./lii.jpeg")#">
Image WriteToBrowser
<cfimage action="writeToBrowser" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4">
Image Rotate
<cfimage action="rotate" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4"
destination="#expandPath( 'rotated.jpg' )#" overwrite="true" angle="30" quality="1">
<cfimage action="writeToBrowser" source="#expandpath("./rotated.jpg")#">
Image Resize
<cfimage action="resize" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4"
name="resize" overwrite="true" height="300" width="400" quality="1">
<cfimage action="writeToBrowser" source="#resize#">
Image border
<cfimage action="border" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4" color="red"
name="withborder">
<cfimage action="writeToBrowser" source="#withborder#">
Script Syntax
Image write
newImg = imageNew("",200,200,"rgb","blue");
cfimage(action="write", source="#newImg#", name="writeimg", destination="pathname", overwrite="true");
Image Captcha
cfimage(action="captcha",text="Captcha!", difficulty="low",height="30",width="150",fontSize="18",
fonts="Comic Sans MS,Times New Roman");
Image Read
cfimage(action="read",name="sourceImage",source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4")
writeDump(sourceImage);
Image Info
cfimage(action="info",structname="sourceImage",source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4")
writeDump(sourceImage);
Image Convert
cfimage(action="convert",structname="sourceImage",destination="#expandpath("./lii.jpeg")#",
source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4" overwrite="true")
cfimage(action="writeToBrowser",source="#expandpath("./lii.jpeg")#")
Image WriteToBrowser
cfimage(action="writeToBrowser",source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4")
Image Rotate
cfimage(action="rotate",source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4",
destination="#expandPath( 'rotated.jpg' )#",overwrite="true",angle="30",quality="1")
cfimage(action="writeToBrowser",source="#expandpath("./rotated.jpg")#")
Image Resize
cfimage(action="resize",source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4",name="resize",
overwrite="true",height="300",width="400",quality="1")
cfimage(action="writeToBrowser",source="#resize#")
Image border
cfimage(action="border" source="https://avatars1.githubusercontent.com/u/10973141?s=280&v=4" color="red" name="withborder");
cfimage(action="writeToBrowser" source="#withborder#");
See also
- Image manipulation
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)