The Flying Meat Wiki : AcornMakeGrayscalePlugin

HomePage :: Categories :: PageIndex :: RecentChanges :: Login/Register
And here is an example which takes the current bitmap layer and converts it to grayscale using CoreImage. It also setups a keyboard shortcut, using Control-Command-G:

MakeGrayscale.py
import objc

ACScriptSuperMenuTitle = "Color"
ACScriptMenuTitle = "Make Grayscale (python)"
ACShortcutKey = 'g'
ACShortcutMask = "command control"

CIColor  = objc.lookUpClass('CIColor')
CIFilter = objc.lookUpClass('CIFilter')

def main(image):
   
    color = CIColor.colorWithRed_green_blue_(0.5, 0.5, 0.5)
   
    filter = CIFilter.filterWithName_('CIColorMonochrome')
    filter.setDefaults()
   
    filter.setValue_forKey_(image, 'inputImage')
    filter.setValue_forKey_(color, 'inputColor')
    filter.setValue_forKey_(1, 'inputIntensity')
   
    return filter.valueForKey_('outputImage')




Back to AcornPlugins
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.3
Page was generated in 0.0495 seconds