GIMP/Scripts/CropFlattenSave
Jump to navigation
Jump to search
- Script name: CropFlattenSave
- Author: Tintazul
- Summary: 1. crops to selection (if any); 2. flatten to remove transparency; 3. save
#!/usr/bin/env python from gimpfu import * def crop_flatten_save(image, layer): #get selection (non_empty, x1, y1, x2, y2) = pdb.gimp_selection_bounds (image) #print 'non_empty: ', non_empty if non_empty: #crop dx, dy = x2-x1, y2-y1 #print 'x1:', x1, 'y1:', y1, 'x2:', x2, 'y2:', y2, 'dx:', dx, 'dy:', dy pdb.gimp_image_crop(image, dx, dy, x1, y1) pdb.gimp_selection_none(image) #remove alpha channel; returns a single layer layer = pdb.gimp_image_flatten(image) #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_crop_flatten_save", "Crops, flattens, and saves the image", "Crops, flattens, and saves the image. Won't crop if there's no selection.", "Julio Reis", #very important note: won't allow accented u "Julio Reis", "2008-08-01", "<Image>/_Gutenberg/_CropFlattenSave", "RGB*, GRAY*, INDEXED*", [], [], crop_flatten_save)