flow>Standard step>Alignment comment>Set up the grid for Rotate and or Perspective Transform comment>Easier to do geometric operations with single layer comment>This first step is run as part of the import jpeg comment>In the console get ID with: theImage = gimp.image_list()[0] comment>First set some variables and establish grid spacing and style >>> centerX = theImage.width/2 >>> centerY = theImage.height/2 >>> gridSpacing = max(theImage.width, theImage.height)/24 >>> pdb.gimp_image_grid_set_offset(theImage, centerX, centerY) >>> pdb.gimp_image_grid_set_spacing(theImage, gridSpacing, gridSpacing) >>> pdb.gimp_image_grid_set_style(theImage, GRID_ON_OFF_DASH) comment>Expand the canvas by 25 percent -easier use to rotate / perspective >>> adjust = max(theImage.height, theImage.width)/4 >>> theImage.resize(theImage.width + adjust, theImage.height+ adjust, adjust/2, adjust/2) comment>Rename the base layer to 'Original' >>> theLayer = theImage.layers[0] >>> theLayer.name = 'Original' step>DynamicRange comment>Shrink the Canvas back to fit the layer >>> theImage.resize_to_layers() comment>Set grid to origin and size = image >>> pdb.gimp_image_grid_set_offset(theImage, 0, 0) >>> pdb.gimp_image_grid_set_spacing(theImage, theImage.width, theImage.height) comment>Capture a new 'Color Layer'. Move it to the bottom of the stack comment>Save 'Color' so we can recover it at the end of the flow comment>We don't have to worry if some of the filters skew the color. comment>We can also use this to amp up the color >>> theImage.active_layer = theImage.layers[0] >>> currentLayer = theImage.active_layer >>> tempLayer = currentLayer.copy() >>> theImage.add_layer(tempLayer, 0) >>> pdb.gimp_desaturate_full(tempLayer, DESATURATE_LUMINOSITY) >>> tempLayer.mode = GRAIN_EXTRACT_MODE >>> colorLayer = pdb.gimp_layer_new_from_visible(theImage, theImage, 'ColorLayer') >>> theImage.add_layer(colorLayer, len(theImage.layers)) >>> colorLayer.mode = GRAIN_MERGE_MODE >>> theImage.remove_layer(tempLayer) >>> theImage.active_layer = theImage.layers[0] comment>Create a Dynamic Range Layer and add it at the top of the stack comment>Run autostretch_hsv leave mode Normal and at 100% opacity comment>May have to use 'Curves' to tune up histogram >>> original = theImage.active_layer >>> DynRange = original.copy() >>> DynRange.name = "DynRange" >>> theImage.add_layer(DynRange, 0) >>> pdb.plug_in_autostretch_hsv(theImage, DynRange) step>Retinex-Filter comment>Add a new Retinex layer and apply the retinex filter with default settings >>> RetinexLayer = pdb.gimp_layer_new_from_visible(theImage, theImage, "Retinex") >>> theImage.add_layer(RetinexLayer,0) comment>Retinex parameters - Scale = 240; ScaleDiv = 3; Level = 0; Dynamic = 1.2 >>> pdb.plug_in_retinex(theImage, RetinexLayer, 240, 3, 0, 1.2) comment>Make the retinex layer B&W - retinex distorts color >>> pdb.gimp_desaturate_full(RetinexLayer, 1) >>> RetinexLayer.mode = OVERLAY_MODE >>> RetinexLayer.opacity = 75.0 comment>Adjust the opacity based on Property EnhanceContrastLevel >>> ContrastLevel = str(theImage.parasite_find('EnhanceContrastLevel')) >>> if (ContrastLevel == 'EXTRA'): RetinexLayer.opacity = 100.0 >>> if (ContrastLevel == 'NORMAL'): RetinexLayer.opacity = 75.0 >>> if (ContrastLevel == 'MID'): RetinexLayer.opacity = 50.0 >>> if (ContrastLevel == 'NONE'): RetinexLayer.opacity = 0.0 step>Sharpen comment>Add a new Sharpend layer and apply the sharpening filter with default settings >>> SharpenLayer = pdb.gimp_layer_new_from_visible(theImage, theImage, "Sharpen") >>> theImage.add_layer(SharpenLayer,0) comment>Sharpen parameters - Radius = 5.0; Amount = 0.5; Threshold = 0 >>> pdb.plug_in_unsharp_mask(theImage, SharpenLayer, 5.0, 0.5, 0) comment>Adjust the opacity based on Property EnhanceContrastLevel >>> SharpenLayer.opacity = 75.0 >>> ContrastLevel = str(theImage.parasite_find('EnhanceContrastLevel')) >>> if (ContrastLevel == 'EXTRA'): SharpenLayer.opacity = 100.0 >>> if (ContrastLevel == 'NORMAL'): SharpenLayer.opacity = 75.0 >>> if (ContrastLevel == 'MID'): SharpenLayer.opacity = 50.0 >>> if (ContrastLevel == 'NONE'): SharpenLayer.opacity = 0.0 step>ColorAdjust #step>Finished comment>Merge the work layers together and raise the color layer to the top comment>First the Retinex layer >>> RetinexLayer = pdb.gimp_image_get_layer_by_name(theImage, 'Retinex') >>> templayer = pdb.gimp_image_merge_down(theImage, RetinexLayer, EXPAND_AS_NECESSARY) comment>Then the Sharpen Layer >>> SharpenLayer = pdb.gimp_image_get_layer_by_name(theImage, 'Sharpen') >>> newLayer = pdb.gimp_image_merge_down(theImage, SharpenLayer, EXPAND_AS_NECESSARY) >>> newLayer.name = 'Contrast' comment>Desaturate the resultant layer >>> pdb.gimp_desaturate_full(newLayer, DESATURATE_LUMINOSITY) comment>Now grab the color layer and move it to the top >>> ColorLayer = pdb.gimp_image_get_layer_by_name(theImage, 'ColorLayer') >>> pdb.gimp_image_raise_item_to_top(theImage, ColorLayer) >>> ColorLayer.opacity = 80.0 comment>Copy the Color Layer, call it ColorAdd, set opacity to 20%. Adjust by hand as needed. >>> ColorAdd = pdb.gimp_layer_copy(ColorLayer, FALSE) >>> theImage.add_layer(ColorAdd, 0) >>> ColorAdd.name = 'ColorAdd' comment>Take a shot at adjusting the Color Layer based on Property EnhanceColorLevel >>> ColorLevel = str(theImage.parasite_find('EnhanceColorLevel')) comment>Set Color level opacity, first setting is default - if clauses fail. >>> ColorAdd.opacity = 20.0 >>> if (ColorLevel == 'EXTRA'): ColorAdd.opacity = 60.0 >>> if (ColorLevel == 'NORMAL'): ColorAdd.opacity = 40.0 >>> if (ColorLevel == 'MID'): ColorAdd.opacity = 20.0 >>> if (ColorLevel == 'NONE'): ColorAdd.opacity = 0.0