| CFX_ImageCR3: |
Website Support Purchase |
|
|
|
| » Welcome » Reference » Examples | Table of Contents : Keyword Index |
|
|
|
| « How does it work? (prev) | (next) Advanced » |
|
|
|
|
Examples On this page you will find CFML examples of ImageCR 3 in use.
Basic
Resizing Cropping Simple Gallery Square Gallery CSS Gallery GetImageInfo Website Screenshot The code listings are automatically formatted to fit the screen. Additionally, CFX_ImageCR attributes in the code are hyperlinked to their definitions. However, the usual link underlines were removed to improve readability.
Click the
Click the Basic
<cfx_imagecr3 load="#expandpath('example.jpg')#"This example loads example.jpg and saves it as example-resaved.jpg. In the process, ImageCR just happens to have optimized this image, reducing the size by over 20k, without a noticable difference in the image quality. The result of this example is a blank page. The tag just performs the operation, it does not output any text or html. Resizing
<cfx_imagecr3 load="#expandpath('example.jpg')#"
Cropping
<cfx_imagecr3 load="#expandpath('example.jpg')#"
Simple Gallery
<cfset dir="#ExpandPath('photos/')#"> <cfdirectory name="dirlist" directory="#dir#" filter="*.jpg"> <cfoutput query="dirlist"> <cfx_imagecr3 load="#dir##dirlist.name#"This example obtains a listing of all jpg files in the "photos" subdirectory. Then, it loops over that list creating thumbnails for each image, saving the thumbnails to the "thumbnails" subdirectory with autonames. Each thumbnail is 100 pixels high, and the width is calculated proportionately. ( see: resize, RectString ) Each thumbnail is displayed and links to the full size image, creating a simple gallery. Be sure to look at a couple of the thumbnails' filenames. They are autonamed since save is a directory. Square Gallery
<cfset dir="#ExpandPath('photos/')#"> <cfdirectory name="dirlist" directory="#dir#" filter="*.jpg"> <cfoutput query="dirlist"> <cfx_imagecr3 load="#dir##dirlist.name#"This is similar to the Simple Gallery, but makes use of boxing modifiers and recrop to create thumbnails of like size regardless of the original image sizes. Resulting thumbnails are 100x100 pixels and edges are cropped as necessary. CSS Gallery
<style> .centeredthumb { width: 100px; height: 100px; background: #f0f0f0 no-repeat center; border: 1px solid #c0c0c0; } </style> <cfset dir="#ExpandPath('photos/')#"> <cfdirectory name="dirlist" directory="#dir#" filter="*.jpg"> <cfoutput query="dirlist"> <cfx_imagecr3 load="#dir##dirlist.name#"This is similar to the Square Gallery, but creates thumbnails without cropping, and centers them in 100x100 blocks with CSS. Note the use of the box-in modifier, "[". This creates images which fit inside a 100 pixel square. GetImageInfo
<cfx_imagecr3 getimageinfo="#expandpath('example.jpg')#" > <cfoutput> <pre> Width = #imagecr.width# Height = #imagecr.height# DPI = #imagecr.dpi# FileSize = #imagecr.filesize# </pre> </cfoutput>This example shows how easy getimageinfo mode is. Image details are retrieved from example.jpg and displayed. Website Screenshot
<cfset bmpfile="#expandpath('efflare.bmp')#"> <cfset giffile="#expandpath('efflare.gif')#"> <cfset gotscreen="#fileexists(bmpfile)#"> <cfif not gotscreen> <cfx_url2bmp url="http://efflare.com" bmp="#bmpfile#"> </cfif> <cfx_imagecr3 load="#bmpfile#"This example shows one of our free tags, cfx_url2bmp, in use alongside cfx_ImageCR to obtain an efficient gif screenshot of http://efflare.com. ImageCR loads the created bmp, crops a 700 pixel wide section from the top center, and saves efficiently as a well suited gif. ( see also : Popular Image Formats)
Take a look at the resulting 25k gif here » cfx_url2bmp is a free, but unsupported, tag one of our developers wrote as a proof of concept one slow weekend. You can download it from our website at http://efflare.com/download/. This technique allows for some interesting implementations. For example, when used with something like the Simple Gallery above you could create contact sheets for groups of images. The possibilities are surprising. |
|||||
|
|
|||||
| « How does it work? (prev) | (next) Advanced » | ||||
|
|
|||||
| Copyright © Efflare Systems | |||||