0% found this document useful (0 votes)
5 views1 page

Convert To Grayscale

This document is a Python script for GIMP that converts the active layer of an image to grayscale. It includes functions to start and end an undo group for the operation, ensuring it can be undone in one step. The script is registered in GIMP with a unique name and menu path for easy access.

Uploaded by

khurshid awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Convert To Grayscale

This document is a Python script for GIMP that converts the active layer of an image to grayscale. It includes functions to start and end an undo group for the operation, ensuring it can be undone in one step. The script is registered in GIMP with a unique name and menu path for easy access.

Uploaded by

khurshid awan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#!

/usr/bin/env python

from gimpfu import *

def convert_to_grayscale(image, drawable):

# Start an undo group, so the operation can be undone in one step

pdb.gimp_image_undo_group_start(image)

# Convert the active layer to grayscale

pdb.gimp_desaturate(drawable)

# End the undo group

pdb.gimp_image_undo_group_end(image)

# Register the script in GIMP

register(

"python_fu_convert_to_grayscale", # Unique name for the script

"Convert Image to Grayscale", # Short description

"This script converts the active layer to grayscale.", # Long description

"Your Name", "Your Name", "2023", # Author, copyright, date

"<Image>/Image/Convert to Grayscale", # Menu path

"RGB*, GRAY*", # Image types (works on RGB and grayscale images)

[], # No input parameters

[], # No output parameters

convert_to_grayscale) # Function to call

main()

You might also like