Eyeon:Script/Reference/Applications/Fuse/Classes/Image/Resize
From VFXPedia
< Eyeon:Script | Reference | Applications | Fuse | Classes | Image
Contents |
Summary
The Resize function resizes an image to the dimensions specified in the functions attributes table. It applies the resized result to the image provided as its first argument.
Usage
Image:Resize(image result, table options)
- result (image, required)
- The image object where the results of the resize will be applied. If none is provided, a new image will be created and returned by the function.
- attributes (table, required)
- A table of options which describe the width, height, filter and other parameters used by the resize function. See the Options section below.
Options
- RSZ_Filter
- A string describing which filter method should be used for the resize. Valid options are :
- TopLeft
- Nearest
- Box
- Linear
- BiLinear
- Quadratic
- BiCubic
- Cubic
- BSpline
- CatmulRom
- Gaussian
- Mitchell
- Lanczos
- Sinc
- Bessel
- RSZ_Window
- A string that specifies the Windowing method to use with Lanczos and Sinc filter methods. Not required for other filter types.
- Hanning
- Hamming
- Blackman
- Kaiser
- RSZ_Width
- An integer specifying the width of the result image in pixels
- RSZ_Height
- An integer specifying the height of the result image in pixels
- RSZ_Depth
- An integer specifying the color depth of the result image, Usually left nil.
- RSZ_XSize
- A numeric value representing the horizontal scale of the result image. Provides an alternate to RSZ_Width. A value of 1.0 represents 100%, or no change.
- RSZ_YSize
- A numeric value representing the vertical scale of the result image. Provides an alternate to RSZ_Height. A value of 1.0 represents 100%, or no change.
Example
The process function from a clone of Fusion's native Scale tool. The complete Fuse can be found at FuseScale.Fuse example found at Example_Fuses
function Process(req) local img = InImage:GetValue(req) local locked = InLockXY:GetValue(req).Value local sizex = InSizeX:GetValue(req).Value local sizey = InSizeY:GetValue(req).Value if locked == 1 then sizey = sizex end local changeaspect = InChangeAspect:GetValue(req).Value local aspect = InAspect:GetValue(req) local filter = InFilter:GetValue(req).Value local window = InWindow:GetValue(req).Value local filters = { "Nearest", "Box", "BiLinear", "BiCubic", "BSpline", "CatmulRom", "Gaussian", "Mitchell", "Lanczos", "Sinc", "Bessel" } local windows = {"Hanning", "Hamming", "Blackman"} if (sizex == 1) and (sizey ==1) then -- don't do a damn thing img:Use() OutImage:Set(req, img) else src_width = img.OriginalWidth src_height = img.OriginalHeight -- is the image fielded? -- I don't have support for that yet! -- work out how big the result image is local width = math.floor( src_width * sizex ) local height = math.floor( src_height * sizey ) -- never let there be an image smaller than 1 pixel width = math.max(width, 1) height = math.max(height, 1) result = Image({IMG_Like = img, IMG_Width = width, IMG_Height = height}) img:Resize(result, { RSZ_Filter = filters[filter+1], RSZ_Window = windows[window+1], RSZ_Width = width, RSZ_Height = height, }) OutImage:Set(req, result) end end
Tips for Resize (edit)
If you specify a result image, Resize() will scale the result to fit its dimensions automatically. In this case, there's no need to specify RSZ_Width or RSZ_Height.