Resizing and saving an image

From The Foundry MODO SDK wiki
Jump to: navigation, search

Description:

Resizing an image

Code:

import lxu.select
 
current_scene = lxu.select.SceneSelection().curent()
sceneService  = lx.service.Scene()
 
# Load image
channelRead  = current_scene.Channels(lx.symbol.s_ACTIONLAYER_EDIT, 0.0)
channelWrite = lx.object.ChannelWrite(channelRead)
videoClip    = current_scene.ItemAdd (sceneService.ItemTypeLookup(lx.symbol.sITYPE_VIDEOSTILL))
channelIndex = videoClip.ChannelLookup(lx.symbol.sICHAN_VIDEOSTILL_FILENAME)
channelWrite.String (videoClip, channelIndex, 'c:/temp/slackAltTab.jpg')
 
# Get to the image object
scene    = videoClip.Context()
channels = lx.object.ChannelRead (scene.Channels(None, 0.0) )
channel  = videoClip.ChannelLookup ("imageStack")
filter   = lx.object.ImageFilter (channels.ValueObj (videoClip, channel))
 
# Generate image, passing a different resolution
image    = lx.object.Image (filter.Generate (150, 150, None))
 
# Save to file
imageService = lx.service.Image()
imageService.Save(image, r'c:\temp\smaller.jpg', 'JPG', 0)