GIMP/Scripts/BlankPage

From DPWiki
< GIMP‎ | Scripts
Jump to navigation Jump to search
  • Script name: BlankPage
  • Author: Tintazul
  • Summary: 1. remove transparency (if any); 2. select everything and clear selection; 3. save
#!/usr/bin/env python

from gimpfu import *

def blank_page(image, layer):
	#remove transparency if it has it
	if pdb.gimp_drawable_has_alpha (layer):
		layer = pdb.gimp_image_flatten (image)
	#get format
	#convert to grayscale if not already
	if not pdb.gimp_drawable_is_gray (layer):
		pdb.gimp_image_convert_grayscale (image)
	#select all
	pdb.gimp_selection_all(image)
	#delete everything
	pdb.gimp_edit_clear(layer)
	#save and remove dirty bit
	name = pdb.gimp_image_get_filename(image)
	pdb.gimp_file_save(image, layer, name, name)
	pdb.gimp_image_clean_all(image)

register(
	"python_fu_blank_page",
	"Turns page to blank",
	"Turns page to blank: converts to grayscale, selects all, deletes, saves.",
	"Julio Reis", #very important note: won't allow accented u
	"Julio Reis",
	"2008-08-01",
	"<Image>/_Gutenberg/_BlankPage",
	"RGB*, GRAY*, INDEXED*",
	[],
	[],
	blank_page)