lucee.Component
models.coldThumbs
ColdThumbs main component ColdThumbs is a ColdFusion component to dynamically resize and cache images.
| Property Summary | ||||
|---|---|---|---|---|
| type | property | default | serializable | required |
array
|
AllowedExtensions
AllowedExtensions.
|
true
|
false
|
|
array
|
AllowedMimeTypes
Supported mime types.
|
true
|
false
|
|
string
|
cacheFolder
Filesystem location of the folder in which to store cached images.
|
true
|
false
|
|
string
|
cacheURL
The URL of the cached folder.
|
cached
|
true
|
false
|
cfconcurrent.ExecutorService
|
ExecutorService
An instance of CFConcurrent.
|
true
|
false
|
|
string
|
imageMagickLocation
Set the location of an ImageMagick binary to use this over native Java image resizing.
|
true
|
false
|
|
string
|
interpolation
Interpolation to use when resizing images.
|
mitchell
|
true
|
false
|
boolean
|
keepFilenames
Keep filenames.
|
true
|
true
|
false
|
numeric
|
maxHeight
The maximum height an image may be output.
|
5000
|
true
|
false
|
numeric
|
maxThreads
Maximum number of threads to spawn.
|
2
|
true
|
false
|
numeric
|
maxWidth
The maximum width an image may be output.
|
5000
|
true
|
false
|
struct
|
queuedThreads
Array to hold calls queued for processing.
|
true
|
false
|
|
struct
|
runningThreads
Struct to hold information about resizing threads.
|
true
|
false
|
|
boolean
|
useThreading
Spawn new threads to resize images.
|
true
|
true
|
false
|
| Constructor Summary | |
|---|---|
|
init()
Constructor. |
|
| Method Summary | |
|---|---|
boolean
|
checkCachedImageExists(string filename)
Checks the cache folder to see if a given file exists. |
string
|
checkCacheFolder()
Create the cache folder if it doesn't exist. |
string
|
generateCachedFilename(struct fileInfo, numeric width, numeric height, [boolean fixCanvas='false'], [string interpolation='[runtime expression]'], [string extension=''])
Generate a cached file name from image file info. |
string
|
getAllowedExtensions()
|
string
|
getAllowedMimeTypes()
|
any
|
getCacheFolder()
Override default getCacheFolder to run through normalise function. |
string
|
getCacheURL()
|
string
|
getExecutorService()
|
any
|
getImageFileInfo(string src, [string authenticationString=''])
Get a struct of file info. |
string
|
getImageMagickLocation()
|
string
|
getInterpolation()
|
string
|
getKeepFilenames()
|
private struct
|
getLocalFileInfo(string path)
Get a struct of file info from a local path. |
string
|
getMaxHeight()
|
string
|
getMaxThreads()
|
string
|
getMaxWidth()
|
any
|
getMemento()
getMemento. |
string
|
getQueuedThreads()
|
private struct
|
getRemoteFileInfo(string url, [string authenticationString=''])
Get a struct of file info from a remote URL. |
string
|
getRunningThreads()
|
any
|
getThumbnail(string src, [string authenticationString=''], [numeric width='0'], [numeric height='0'], [string imageType=''], [boolean fixCanvas='false'], [string interpolation='[runtime expression]'], [string backgroundColor], [boolean regenerate='false'], [boolean useThreading='[runtime expression]'])
Retrieve a thumbnail from the cache or generate a new one from source. |
string
|
getUseThreading()
|
private boolean
|
isRequestInThread()
Check to see if the current request is in a thread, as we can't have nested threads. |
private any
|
normalisePath(string path)
Normalise the file path by replacing back slashes and removing duplicates. |
private any
|
processQueue()
Process images stored in the thread queue. |
private any
|
resizeImage(struct theImage, string cachedFilename, struct fileInfo, numeric width, numeric height, [boolean fixCanvas='false'], [string interpolation='[runtime expression]'], [string backgroundColor], [string authenticationString=''])
Resize the image. |
private any
|
resizeImageInThread(struct theImage, string cachedFilename, struct fileInfo, [string authenticationString=''], [numeric width='0'], [numeric height='0'], [boolean fixCanvas='false'], [string interpolation='[runtime expression]'], [string backgroundColor])
Spawn a new thread to resize an image. |
any
|
setAllowedExtensions(array AllowedExtensions)
|
any
|
setAllowedMimeTypes(array AllowedMimeTypes)
|
any
|
setCacheFolder(string cacheFolder)
|
any
|
setCacheURL(string cacheURL)
|
any
|
setExecutorService(cfconcurrent.ExecutorService ExecutorService)
|
any
|
setImageMagickLocation(string imageMagickLocation)
|
any
|
setInterpolation(string interpolation)
|
any
|
setKeepFilenames(boolean keepFilenames)
|
any
|
setMaxHeight(numeric maxHeight)
|
any
|
setMaxThreads(numeric maxThreads)
|
any
|
setMaxWidth(numeric maxWidth)
|
any
|
setQueuedThreads(struct queuedThreads)
|
any
|
setRunningThreads(struct runningThreads)
|
any
|
setUseThreading(boolean useThreading)
|
string
|
writeImageToCache(any imageObject, string filename)
Write an image to the cache folder. |
| Methods inherited from class lucee.Component |
|---|
| None |
| Constructor Detail |
|---|
Constructor
| Property Detail |
|---|
AllowedExtensions
access - publicrequired - falsereturntype - anyserializable - trueSupported mime types
access - publicrequired - falsereturntype - anyserializable - trueFilesystem location of the folder in which to store cached images
access - publicrequired - falsereturntype - anyserializable - trueThe URL of the cached folder This will be included in returned URLs
access - publicrequired - falsereturntype - anyserializable - trueAn instance of CFConcurrent.ExecutorService - https://github.com/pixl8/cfconcurrent When available, ColdThumbs will use the CFConcurrent framework to handle threading over native CFThread
access - publicrequired - falsereturntype - anyserializable - trueSet the location of an ImageMagick binary to use this over native Java image resizing.
access - publicrequired - falsereturntype - anyserializable - trueInterpolation to use when resizing images
access - publicrequired - falsereturntype - anyserializable - trueKeep filenames. When true, the cached name will retain the original filename with a truncated hash. Use when it is desirable for keywords to be included in returned images.
access - publicrequired - falsereturntype - anyserializable - trueThe maximum height an image may be output. Use this to avoid huge images that may hog server resources to generate
access - publicrequired - falsereturntype - anyserializable - trueMaximum number of threads to spawn. Remaining image processing requests will be held in a queue.
access - publicrequired - falsereturntype - anyserializable - trueThe maximum width an image may be output. Use this to avoid huge images that may hog server resources to generate
access - publicrequired - falsereturntype - anyserializable - trueArray to hold calls queued for processing
access - publicrequired - falsereturntype - anyserializable - trueStruct to hold information about resizing threads
access - publicrequired - falsereturntype - anyserializable - trueSpawn new threads to resize images
access - publicrequired - falsereturntype - anyserializable - true| Method Detail |
|---|
Checks the cache folder to see if a given file exists
filename - (required) The image file nameCreate the cache folder if it doesn't exist
Generate a cached file name from image file info
fileInfo - Struct of image file information generated by the getLocalFileInfo or getRemoteFileInfo functionswidth - Width of cached fileheight - Height of cached filefixCanvas - Whether the fixCanvas flag was setinterpolation - Interpolation to use for the resizingextension - Override the file extensionOverride default getCacheFolder to run through normalise function
Get a struct of file info
src - (required) The location (path or URL) of the imageauthenticationString - An authentication string if one is required (user:pass)Get a struct of file info from a local path
path - (required) The path of the imagegetMemento
Get a struct of file info from a remote URL
url - (required) The URL of the imageauthenticationString - An authentication string if one is required (user:pass)Retrieve a thumbnail from the cache or generate a new one from source
src - (required) The location (path or URL) of the imageauthenticationString - An authentication string if one is required (user:pass)width - Width of cached fileheight - Height of cached fileimageType - Convert the resized image to a different type: (JPG|GIF|PNG|BMP) - Matches the source image type by default.fixCanvas - When true, fix the canvas size to the specified dimensions, whilst proportionally resizing the content. e.g. You may want to create a uniform square image from a portrait or landscape image.interpolation - Interpolation to use for the resizingbackgroundColor - When using the fixCanvas method, the resulting image may contain a blank area that should be filled with a colour. (hex or r,g,b)regenerate - When true, force the regeneration of the thumbnail overwriting an existing image in the cacheuseThreading - When true, the image will spawn a new thread in which the resize process will occur.Check to see if the current request is in a thread, as we can't have nested threads Thanks to Mark Mandel: https://www.compoundtheory.com/how-to-tell-if-code-is-being-run-inside-a-cfthread-tag/
Normalise the file path by replacing back slashes and removing duplicates
path - (Required) the path to normaliseProcess images stored in the thread queue
Resize the image
theImage - The extended image objectcachedFilename - The filename to use when saving the cached imagefileInfo - A struct of file infowidth - Width of cached fileheight - Height of cached filefixCanvas - When true, fix the canvas size to the specified dimensions, whilst proportionally resizing the content. e.g. You may want to create a uniform square image from a portrait or landscape image.interpolation - Interpolation to use for the resizingbackgroundColor - When using the fixCanvas method, the resulting image may contain a blank area that should be filled with a colour. (hex or r,g,b)authenticationString - An authentication string if one is required (user:pass)Spawn a new thread to resize an image
theImage - The extended image objectcachedFilename - The filename to use when saving the cached imagefileInfo - A struct of file infoauthenticationString - An authentication string if one is required (user:pass)width - Width of cached fileheight - Height of cached filefixCanvas - When true, fix the canvas size to the specified dimensions, whilst proportionally resizing the content. e.g. You may want to create a uniform square image from a portrait or landscape image.interpolation - Interpolation to use for the resizingbackgroundColor - When using the fixCanvas method, the resulting image may contain a blank area that should be filled with a colour. (hex or r,g,b)AllowedExtensionsAllowedMimeTypescacheFoldercacheURLExecutorServiceimageMagickLocationinterpolationkeepFilenamesmaxHeightmaxThreadsmaxWidthqueuedThreadsrunningThreadsuseThreadingWrite an image to the cache folder
imageObject - (required) The image object to write to the cachefilename - (required) The filename to use when writing to the cache