|
ColdFusion 9.0 Resources |
ImageGetBlobDescriptionRetrieves the bytes of the underlying image. The bytes are in the same image format as the source image. See alsocfimage, ImageGetBufferedImage, ImageGetEXIFTag, ImageGetHeight, ImageGetIPTCTag, ImageGetWidth, ImageInfo, IsImage Parameters
ExampleExample 1 <!--- This example shows how to add a ColdFusion image to a database. --->
<!--- Create ColdFusion image from a an existing JPEG file. --->
<cfimage source="aiden01.jpg" name="myImage">
<!--- Use the cfquery tag to insert the ColdFusion image as a BLOB in the database. --->
<cfquery name="InsertBlobImage" datasource="myBlobData" >
INSERT into EMPLOYEES (FirstName,LastName,Photo)
VALUES ('Aiden','Quinn',<cfqueryparam value="#ImageGetBlob(myImage)#" cfsqltype='cf_sql_blob'>)
</cfquery>
Example 2 The following example shows how to use the ImageNew function to generate thumbnail images in JPEG format from BLOB data retrieved from a database: <!--- Use the cfquery tag to retrieve all employee photos and employee IDs from a database. --->
<cfquery name= "GetBLOBs" datasource= "myBlobData">
SELECT EMLPOYEEID, PHOTO FROM Employees
</cfquery>
<!--- Use the ImageNew function to create a ColdFusion image from the BLOB data that was retrieved from the database. --->
<cfset myImage = ImageNew(#GetBLOBs.PHOTO#)>
<!--- Create thumbnail versions of the images by resizing them to a 100x100-pixel image, while maintaining the aspect ratio of the
source image. --->
<cfset ImageScaleToFit(myImage,100,"")>
<!--- Convert the images to JPEG format and save them to files in the thumbnails subdirectory, using the employee ID as the filename. --->
<cfimage source="#myImage#" action-"write" destination="images/thumbnails/#GetBLOBs.EMPLOYEID#.jpg">
|