#!/usr/bin/perl # Convert a Script-Fu script from the 1.0 API interface to the new 2.x API. # Created January 28, 2004 by Kevin Cozens # # This script changes references to deprecated functions and constants # so they conform to the new 2.x API. If this script is applied to a script # which already conforms to the 2.x API, only deprecated constants will # be updated. No changes will be made to functions which already conform # to the 2.x API. # # ------------------------------------------------------------------------- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ------------------------------------------------------------------------- # # Changed on January 29, 2004 by Kevin Cozens # Modified to change deprecated constants to conform to the 2.0 API. # Modified to remove 'img' argument from two deprecated function calls. # Modified to add missing arguments to deprecated gimp-blend function call. # Modified to add missing argument to plug-in-edge call. # # Changed on January 30, 2004 by Kevin Cozens # Prevented change to plug-in-edge call that already conforms to the 2.0 API. # # Changed on February 2, 2004 by Kevin Cozens # Now handles conversion of constants whether they use _ or -. # # Changed on February 7, 2006 by Kevin Cozens # Added list of function name changes needed for GIMP 2.2. # # Changed on June 16, 2006 by Kevin Cozens # Updated list of function name changes needed as of GIMP 2.2.11. # Added list of function name changes needed for GIMP 2.3/2.4. # # Changed on July 21, 2006 by Kevin Cozens # Read the entire script to be modified in to one variable and # operate on that variable. This means items which need to be # updated but are spread over multiple lines will be updated. # Also added check for white space after function name to prevent # incorrect partial matches. # # Changed on October 31, 2006 by Kevin Cozens # Updated the list of functions that have been deprecated in the 2.0, # 2.2, and 2.4 versions of GIMP. Added missing deprecated constants. # Check a command line parameter to determine the target version of # GIMP when updating a script. The default target version is set so # that all updates will be done. Usage information will be displayed # if the command line argument is not recognized. # # Changed on March 17, 2007 by Kevin Cozens # Calls to 'verbose' will be removed when updating for GIMP 2.4. # # Changed on March 19, 2007 by Kevin Cozens # Added missing checks for whitespace in loops which updated function # calls. # # Changed on October 4, 2007 by Kevin Cozens # Updated list of deprecated functions in GIMP 2.4. # # Changed on November 25, 2007 by Kevin Cozens # Used PDB dumps from GIMP 1.0 and 1.2 to update this script. # # Changed on February 8, 2011 by Kevin Cozens # Updated list of deprecated functions in GIMP 2.6 and 2.7. # # Changed on October 29, 2011 by Kevin Cozens # Updated list of deprecated functions 2.7. # # Changed on November 3, 2011 by Kevin Cozens # Changes and bug fixes in handling command line arguments. #Release dates for various versions of GIMP: #GIMP 1.0 1998-06-05 18:39:50 #GIMP 1.2 2000-12-25 03:08:08 #GIMP 2.0 2004-03-23 13:31:35 #GIMP 2.2 2004-12-18 21:37:28 #GIMP 2.4 2007-10-24 (No GIT version was tagged with GIMP_2_4_0) #GIMP 2.6 2008-09-30 17:56:42 #The following affects GIMP 2.2 #2004-10-26 Sven Neumann (version 1.1) # * New transform API was added to the PDB. # *app/core/gimpdrawable-transform.[ch]: added missing parameters # to gimp_drawable_transform_flip() #2004-11-02 Michael Natterer (version 1.5) # * tools/pdbgen/pdb/drawable_transform.pdb (flip): renamed # parameter "center" to "auto_center" and removed # "transform_direction". Renamed rotate() to rotate_free() and # added a "gboolean auto_center" parameter. Added new function # rotate() which takes enum GimpRotationType instead of an # arbitrary angle so the flip and rotate APIs are symmetric. #2004-11-02 Michael Natterer (version 1.6) # * tools/pdbgen/pdb/drawable_transform.pdb: renamed flip() and # rotate() to flip_simple() and rotate_simple(). Renamed flip_free() # and rotate_free() to flip() and rotate() (the special cases should # have a special suffix, not the general ones). #The information in the following arrays came from: # libgimp/gimpcompat.h # plug-ins/script-fu/siod/siod-wrapper.c %constants_1_2 = ( "BLUR", "BLUR-CONVOLVE", "SHARPEN", "SHARPEN-CONVOLVE", "NORMAL", "NORMAL-MODE", "DISSOLVE", "DISSOLVE-MODE", "BEHIND", "BEHIND-MODE", "MULTIPLY", "MULTIPLY-MODE", "SCREEN", "SCREEN-MODE", "OVERLAY", "OVERLAY-MODE", "DIFFERENCE", "DIFFERENCE-MODE", "ADDITION", "ADDITION-MODE", "SUBTRACT", "SUBTRACT-MODE", "DARKEN[_-]ONLY", "DARKEN-ONLY-MODE", "LIGHTEN[_-]ONLY", "LIGHTEN-ONLY-MODE", "HUE", "HUE-MODE", "SATURATION", "SATURATION-MODE", "COLOR", "COLOR-MODE", "VALUE", "VALUE-MODE", "DIVIDE", "DIVIDE-MODE" ); %constants_2_0 = ( "RGB[_-]IMAGE", "RGB-IMAGE", "RGBA[_-]IMAGE", "RGBA-IMAGE", "GRAY[_-]IMAGE", "GRAY-IMAGE", "GRAYA[_-]IMAGE", "GRAYA-IMAGE", "INDEXED[_-]IMAGE", "INDEXED-IMAGE", "INDEXEDA[_-]IMAGE", "INDEXEDA-IMAGE", "WHITE[_-]MASK", "ADD-WHITE-MASK", "BLACK[_-]MASK", "ADD-BLACK-MASK", "ALPHA[_-]MASK", "ADD-ALPHA-MASK", "SELECTION[_-]MASK", "ADD-SELECTION-MASK", "COPY[_-]MASK", "ADD-COPY-MASK", "ADD", "CHANNEL-OP-ADD", "SUB", "CHANNEL-OP-SUBTRACT", "REPLACE", "CHANNEL-OP-REPLACE", "INTERSECT", "CHANNEL-OP-INTERSECT", "FG[_-]BG[_-]RGB", "FG-BG-RGB-MODE", "FG[_-]BG[_-]HSV", "FG-BG-HSV-MODE", "FG[_-]TRANS", "FG-TRANSPARENT-MODE", "CUSTOM", "CUSTOM-MODE", "FG[_-]IMAGE[_-]FILL", "FOREGROUND-FILL", "BG[_-]IMAGE[_-]FILL", "BACKGROUND-FILL", "WHITE[_-]IMAGE[_-]FILL", "WHITE-FILL", "TRANS[_-]IMAGE[_-]FILL", "TRANSPARENT-FILL", "APPLY", "MASK-APPLY", "DISCARD", "MASK-DISCARD", "HARD", "BRUSH-HARD", "SOFT", "BRUSH-SOFT", "CONTINUOUS", "PAINT-CONSTANT", "INCREMENTAL", "PAINT-INCREMENTAL", "HORIZONTAL", "ORIENTATION-HORIZONTAL", "VERTICAL", "ORIENTATION-VERTICAL", "UNKNOWN", "ORIENTATION-UNKNOWN", "LINEAR", "GRADIENT-LINEAR", "BILINEAR", "GRADIENT-BILINEAR", "RADIAL", "GRADIENT-RADIAL", "SQUARE", "GRADIENT-SQUARE", "CONICAL[_-]SYMMETRIC", "GRADIENT-CONICAL-SYMMETRIC", "CONICAL[_-]ASYMMETRIC", "GRADIENT-CONICAL-ASYMMETRIC", "SHAPEBURST[_-]ANGULAR", "GRADIENT-SHAPEBURST-ANGULAR", "SHAPEBURST[_-]SPHERICAL", "GRADIENT-SHAPEBURST-SPHERICAL", "SHAPEBURST[_-]DIMPLED", "GRADIENT-SHAPEBURST-DIMPLED", "SPIRAL[_-]CLOCKWISE", "GRADIENT-SPIRAL-CLOCKWISE", "SPIRAL[_-]ANTICLOCKWISE", "GRADIENT-SPIRAL-ANTICLOCKWISE", "VALUE[_-]LUT", "HISTOGRAM-VALUE", "RED[_-]LUT", "HISTOGRAM-RED", "GREEN[_-]LUT", "HISTOGRAM-GREEN", "BLUE[_-]LUT", "HISTOGRAM-BLUE", "ALPHA[_-]LUT", "HISTOGRAM-ALPHA" ); #List of GIMP 1.0 functions which need the img parameter to be removed #when updating a script for use with version 1.2 of GIMP. %functions_drop_img = ( "gimp_airbrush", "gimp_blend", "gimp_brightness_contrast", "gimp_bucket_fill", "gimp_by_color_select", "gimp_channel_ops_offset", "gimp_clone", "gimp_color_balance", "gimp_color_picker", "gimp_convolve", "gimp_curves_explicit", "gimp_curves_spline", "gimp_desaturate", "gimp_edit_clear", "gimp_edit_copy", "gimp_edit_cut", "gimp_edit_fill", "gimp_edit_paste", "gimp_edit_stroke", "gimp_equalize", "gimp_eraser", "gimp_flip", "gimp_fuzzy_select", "gimp_histogram", "gimp_hue_saturation", "gimp_invert", "gimp_levels", "gimp_paintbrush", "gimp_pencil", "gimp_perspective", "gimp_posterize", "gimp_rotate", "gimp_scale", "gimp_selection_float", "gimp_selection_layer_alpha", "gimp_selection_load", "gimp_shear", "gimp_threshold" ); #Changes needed for GIMP 1.2 %functions_1_2 = ( "gimp-drawable-channel", "gimp-drawable-is-channel", "gimp-drawable-color", "gimp-drawable-is-color", "gimp-drawable-gray", "gimp-drawable-is-gray", "gimp-drawable-indexed", "gimp-drawable-is-indexed", "gimp-drawable-layer", "gimp-drawable-is-layer", "gimp-drawable-layer-mask", "gimp-drawable-is-layer-mask", "gimp-image-disable-undo", "gimp-image-undo-disable", "gimp-image-enable-undo", "gimp-image-undo-enable", "gimp-list-images", "gimp-image-list", "gimp-message-handler-get", "gimp-message-get-handler", "gimp-message-handler-set", "gimp-message-set-handler", "gimp-text-ext", "gimp-text", "gimp-text-get-extents-ext", "gimp-text-get-extents" ); #Changes needed for GIMP 2.0 %functions_2_0 = ( #This function was added in GIMP 1.2 but is now obsolete #and has no direct replacement: # "gimp-drawable-set-image", "", "gimp-brush-select-widget-close-popup", "gimp-brush-select-widget-close", "gimp-brush-select-widget", "gimp-brush-select-widget-new", "gimp-brush-select-widget-set-popup", "gimp-brush-select-widget-set", "gimp-brushes-list", "gimp-brushes-get-list", "gimp-bucket-fill", "gimp-edit-bucket-fill", "gimp-channel-delete", "gimp-drawable-delete", "gimp-channel-get-image-id", "gimp-drawable-get-image", "gimp-channel-get-name", "gimp-drawable-get-name", "gimp-channel-get-tattoo", "gimp-drawable-get-tattoo", "gimp-channel-get-visible", "gimp-drawable-get-visible", "gimp-channel-ops-duplicate", "gimp-image-duplicate", "gimp-channel-ops-duplicate", "gimp-image-duplictate", "gimp-channel-ops-offset", "gimp-drawable-offset", "gimp-channel-set-name", "gimp-drawable-set-name", "gimp-channel-set-tattoo", "gimp-drawable-set-tattoo", "gimp-channel-set-visible", "gimp-drawable-set-visible", "gimp-color-picker", "gimp-image-pick-color", "gimp-convert-grayscale", "gimp-image-convert-grayscale", "gimp-convert-indexed", "gimp-image-convert-indexed", "gimp-convert-rgb", "gimp-image-convert-rgb", "gimp-crop", "gimp-image-crop", "gimp-drawable-bytes", "gimp-drawable-bpp", "gimp-drawable-image", "gimp-drawable-get-image", "gimp-drawable-image-id", "gimp-drawable-get-image", "gimp-drawable-name", "gimp-drawable-get-name", "gimp-drawable-visible", "gimp-drawable-get-visible", "gimp-font-select-widget-close-popup", "gimp-font-select-widget-close", "gimp-font-select-widget", "gimp-font-select-widget-new", "gimp-font-select-widget-set-popup", "gimp-font-select-widget-set", "gimp-gradient-select-widget-close-popup", "gimp-gradient-select-widget-close", "gimp-gradient-select-widget", "gimp-gradient-select-widget-new", "gimp-gradient-select-widget-set-popup", "gimp-gradient-select-widget-set", "gimp-gradients-get-active", "gimp-gradients-get-gradient", "gimp-gradients-set-active", "gimp-gradients-set-gradient", "gimp-image-active-drawable", "gimp-image-get-active-drawable", "gimp-image-floating-selection", "gimp-image-get-floating-sel", "gimp-interactive-selection-brush", "gimp-brush-select-new", "gimp-interactive-selection-font", "gimp-font-select-new", "gimp-interactive-selection-gradient", "gimp-gradient-select-new", "gimp-interactive-selection-pattern", "gimp-pattern-select-new", "gimp-layer-delete", "gimp-drawable-delete", "gimp-layer-get-image-id", "gimp-drawable-get-image", "gimp-layer-get-linked", "gimp-drawable-get-linked", "gimp-layer-get-mask-id", "gimp-layer-get-mask", "gimp-layer-get-name", "gimp-drawable-get-name", "gimp-layer-get-preserve-transparency", "gimp-layer-get-preserve-trans", "gimp-layer-get-tattoo", "gimp-drawable-get-tattoo", "gimp-layer-get-visible", "gimp-drawable-get-visible", "gimp-layer-is-floating-selection", "gimp-layer-is-floating-sel", "gimp-layer-mask", "gimp-layer-get-mask", "gimp-layer-set-linked", "gimp-drawable-set-linked", "gimp-layer-set-name", "gimp-drawable-set-name", "gimp-layer-set-preserve-transparency", "gimp-layer-set-preserve-trans", "gimp-layer-set-tattoo", "gimp-drawable-set-tattoo", "gimp-layer-set-visible", "gimp-drawable-set-visible", "gimp-palette-refresh", "gimp-palettes-refresh", "gimp-pattern-select-widget-close-popup", "gimp-pattern-select-widget-close", "gimp-pattern-select-widget", "gimp-pattern-select-widget-new", "gimp-pattern-select-widget-set-popup", "gimp-pattern-select-widget-set", "gimp-patterns-list", "gimp-patterns-get-list", "gimp-temp-PDB-name", "gimp-procedural-db-temp-name", "gimp-undo-push-group-end", "gimp-image-undo-group-end", "gimp-undo-push-group-start", "gimp-image-undo-group-start" ); #Changes needed for GIMP 2.2 %functions_2_2 = ( "gimp-brushes-get-opacity", "gimp-context-get-opacity", "gimp-brushes-get-paint-mode", "gimp-context-get-paint-mode", "gimp-brushes-get-brush", "gimp-context-get-brush", "gimp-brushes-get-brush-data", "gimp-brush-get-pixels", "gimp-brushes-set-brush", "gimp-context-set-brush", "gimp-brushes-set-opacity", "gimp-context-set-opacity", "gimp-brushes-set-paint-mode", "gimp-context-set-paint-mode", "gimp-gradients-get-gradient", "gimp-context-get-gradient", "gimp-gradients-get-gradient-data", "gimp-gradient-get-uniform-samples", "gimp-gradients-set-gradient", "gimp-context-set-gradient", "gimp-image-get-cmap", "gimp-image-get-colormap", "gimp-image-set-cmap", "gimp-image-set-colormap", "gimp-levels-auto", "gimp-levels-stretch", "gimp-palette-get-background", "gimp-context-get-background", "gimp-palette-get-foreground", "gimp-context-get-foreground", "gimp-palette-set-background", "gimp-context-set-background", "gimp-palette-set-default-colors", "gimp-context-set-default-colors", "gimp-palette-set-foreground", "gimp-context-set-foreground", "gimp-palette-swap-colors", "gimp-context-swap-colors", "gimp-palettes-get-palette", "gimp-context-get-palette", "gimp-palettes-get-palette-entry", "gimp-palette-entry-get-color", "gimp-palettes-set-palette", "gimp-context-set-palette", "gimp-patterns-set-pattern", "gimp-context-set-pattern", "gimp-patterns-get-pattern", "gimp-context-get-pattern", "gimp-patterns-get-pattern-data", "gimp-pattern-get-pixels", "gimp-selection-clear", "gimp-selection-none", "plug-in-blur-randomize-pick", "plug-in-randomize-pick", ); #All functions switched to using - instead of _ as of this GIMP release #Additional changes needed for GIMP 2.4 %functions_2_4 = ( "gimp-blend", "gimp-edit-blend", "gimp-get-path-by-tattoo", "gimp-image-get-vectors-by-tattoo", "gimp-gradients-get-active", "gimp-context-get-gradient", "gimp-gradients-set-active", "gimp-context-set-gradient", "gimp-layer-get-preserve-trans", "gimp-layer-get-lock-alpha", "gimp-layer-set-preserve-trans", "gimp-layer-set-lock-alpha", "gimp-path-delete", "gimp-image-remove-vectors", "gimp-path-get-current", "gimp-image-get-active-vectors", "gimp-path-get-locked", "gimp-vectors-get-linked", "gimp-path-get-point-at-dist", "gimp-vectors-stroke-get-point-at-dist", "gimp-path-get-points", "gimp-vectors-stroke-get-points", "gimp-path-get-tattoo", "gimp-vectors-get-tattoo", "gimp-path-import", "gimp-vectors-import-from-file", "gimp-path-list", "gimp-image-get-vectors", "gimp-path-set-current", "gimp-image-set-active-vectors", "gimp-path-set-locked", "gimp-vectors-set-linked", "gimp-path-set-points", "gimp-vectors-stroke-new-from-points", "gimp-path-set-tattoo", "gimp-vectors-set-tattoo", "gimp-path-stroke-current", "gimp-edit-stroke-vectors", "gimp-path-to-selection", "gimp-vectors-to-selection" ); #Additional changes needed for GIMP 2.6 %functions_2_6 = ( "gimp-image-free-shadow", "gimp-drawable-free-shadow" ); #Additional changes needed for GIMP 2.8 %functions_2_8 = ( "gimp-channel-delete", "gimp-item-delete", "gimp-channel-get-name", "gimp-item-get-name", "gimp-channel-get-tattoo", "gimp-item-get-tattoo", "gimp-channel-get-visible", "gimp-item-get-visible", "gimp-channel-set-name", "gimp-item-set-name", "gimp-channel-set-tattoo", "gimp-item-set-tattoo", "gimp-channel-set-visible", "gimp-item-set-visible", "gimp-drawable-delete", "gimp-item-delete", "gimp-drawable-get-image", "gimp-item-get-image", "gimp-drawable-get-linked", "gimp-item-get-linked", "gimp-drawable-get-name", "gimp-item-get-name", "gimp-drawable-get-tattoo", "gimp-item-get-tattoo", "gimp-drawable-get-visible", "gimp-item-get-visible", "gimp-drawable-is-channel", "gimp-item-is-channel", "gimp-drawable-is-layer", "gimp-item-is-layer", "gimp-drawable-is-layer-mask", "gimp-item-is-layer-mask", "gimp-drawable-is-text-layer", "gimp-item-is-text-layer", "gimp-drawable-is-valid", "gimp-item-is-valid", "gimp-drawable-parasite-attach", "gimp-item-attach-parasite", "gimp-drawable-parasite-detach", "gimp-item-detach-parasite", "gimp-drawable-parasite-find", "gimp-item-get-parasite", "gimp-drawable-parasite-list", "gimp-item-get-parasite-list", "gimp-drawable-set-linked", "gimp-item-set-linked", "gimp-drawable-set-name", "gimp-item-set-name", "gimp-drawable-set-tattoo", "gimp-item-set-tattoo", "gimp-drawable-set-visible", "gimp-item-set-visible", "gimp-image-get-channel-position", "gimp-image-get-item-position", "gimp-image-get-layer-position", "gimp-image-get-item-position", "gimp-image-get-vectors-position", "gimp-image-get-item-position", "gimp-image-lower-channel", "gimp-image-lower-item", "gimp-image-lower-layer", "gimp-image-lower-item", "gimp-image-lower-layer-to-bottom", "gimp-image-lower-item-to-bottom", "gimp-image-lower-vectors", "gimp-image-lower-item", "gimp-image-lower-vectors-to-bottom", "gimp-image-lower-item-to-bottom", "gimp-image-parasite-attach", "gimp-image-attach-parasite", "gimp-image-parasite-detach", "gimp-image-detach-parasite", "gimp-image-parasite-find", "gimp-image-get-parasite", "gimp-image-parasite-list", "gimp-image-get-parasite-list", "gimp-image-raise-channel", "gimp-image-raise-item", "gimp-image-raise-layer", "gimp-image-raise-item", "gimp-image-raise-layer-to-top", "gimp-image-raise-item-to-top", "gimp-image-raise-vectors", "gimp-image-raise-item", "gimp-image-raise-vectors-to-top", "gimp-image-raise-item-to-top", "gimp-layer-delete", "gimp-item-delete", "gimp-layer-get-linked", "gimp-item-get-linked", "gimp-layer-get-name", "gimp-item-get-name", "gimp-layer-get-tattoo", "gimp-item-get-tattoo", "gimp-layer-get-visible", "gimp-item-get-visible", "gimp-layer-set-linked", "gimp-item-set-linked", "gimp-layer-set-name", "gimp-item-set-name", "gimp-layer-set-tattoo", "gimp-item-set-tattoo", "gimp-layer-set-visible", "gimp-item-set-visible", "gimp-parasite-attach", "gimp-attach-parasite", "gimp-parasite-detach", "gimp-detach-parasite", "gimp-parasite-find", "gimp-get-parasite", "gimp-parasite-list", "gimp-get-parasite-list", "gimp-text-layer-get-hinting", "gimp-text-layer-get-hint-style", "gimp-vectors-get-image", "gimp-item-get-image", "gimp-vectors-get-linked", "gimp-item-get-linked", "gimp-vectors-get-name", "gimp-item-get-name", "gimp-vectors-get-tattoo", "gimp-item-get-tattoo", "gimp-vectors-get-visible", "gimp-item-get-visible", "gimp-vectors-is-valid", "gimp-item-is-valid", "gimp-vectors-parasite-attach", "gimp-item-attach-parasite", "gimp-vectors-parasite-detach", "gimp-item-detach-parasite", "gimp-vectors-parasite-find", "gimp-item-get-parasite", "gimp-vectors-parasite-list", "gimp-item-get-parasite-list", "gimp-vectors-set-linked", "gimp-item-set-linked", "gimp-vectors-set-name", "gimp-item-set-name", "gimp-vectors-set-tattoo", "gimp-item-set-tattoo", "gimp-vectors-set-visible", "gimp-item-set-visible", ); # Default to updating scripts from GIMP 2.0 to the most recent version of GIMP $from_version = 20; $to_version = 30; while (@ARGV > 0) { $arg = $ARGV[0]; if ($arg eq "-from") { $from_version = $ARGV[1]; if ($from_version < 10 || $from_version > 26) { $arg = "-h"; } shift(ARGV); } if ($arg eq "-to") { $to_version = $ARGV[1]; if ($to_version < 10 || $to_version > 30) { $arg = "-h"; } shift(ARGV); } if ($from_version >= $to_version) { print "The -to version must be higher than -from version.\n\n"; $arg = "-h"; } if ($arg eq "-h" || $arg eq "--help") { print "Usage: $0 [-h|--help|-from xx|-to yy]\n"; print " -h, --help Show this usage information\n"; print " -from xx Script was written for version xx of GIMP\n"; print " -to yy Output script for use with version yy of GIMP\n"; print "\n"; print "GIMP version number should be one:\n"; print " 10, 12, 20, 22, 24, 26, 28\n"; print "\n"; print " The script to be updated is read from stdin.\n"; print " The updated script is written to stdout.\n"; print "\n"; exit; } shift(ARGV); } #Read the script in as one big string. This allows the pattern matching #statements (further down in this program) to recognize functions which #are split across multiple lines. @lines = <>; $script = join("", @lines); if ($from_version < 12 && $to_version >= 12) { #Replace deprecated constants with the name of a current constant foreach $old_constant (keys(%constants_1_2)) { #To avoid an incorrect match, check for white space or a bracket #before and after the constant to ensure we don't falsely match #a portion of some other constant. $script =~ s/([(\s])$old_constant([)\s])/\1$constants_1_2{$old_constant}\2/g; } #Change lines containing a quoted string inside quotes to SF-STRING. $script =~ s/(SF-VALUE|SF-STRING)(\s+".*"\s+)\"\\\"(.*)\\\"\"/SF-STRING\2\"\3\"/g; #Change lines that appear to contain a font specification to SF-FONT. $script =~ s/(SF-VALUE|SF-STRING)(\s+".*[Ff]ont"\s+".*")/SF-FONT\2/g; #Change lines that appear to contain a pattern reference to SF-PATTERN. $script =~ s/(SF-VALUE|SF-STRING)(\s+".*[Pp]attern"\s+".*")/SF-PATTERN\2/g; #Remove the img parameter from a number of old GIMP 1.0 functions. foreach $old_function (%functions_drop_img) { $script =~ s/([(\s]*$old_function)\s+\S+/\1/g; } #Replace deprecated 1.0 functions with the equivalent 1.2 function foreach $old_function (keys(%functions_1_2)) { #Include white space after function name to avoid an incorrect match. $script =~ s/([(\s])$old_function([)\s])/\1$functions_1_2{$old_function}\2/g; } $script =~ s/(\(\s*gimp-convert-indexed\s+\S+\s+\S+)(\s+\S+)(\s*\))/\1 MAKE-PALETTE\2 FALSE FALSE ""\3/g; $script =~ s/(\(\s*)gimp-eraser-extended(\s+\S+)(\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+)(\s*\))/\1gimp-eraser\3\4/g; $script =~ s/(\(\s*gimp-paintbrush)(\s+\S+)(\s+\S+\s+\S+\s+\S+\s+\S+)(\s*\))/\1\3 CONTINUOUS 0\4/g; $script =~ s/(\(\s*)gimp-paintbrush-extended(\s+\S+)(\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+)(\s*\))/\1gimp-paintbrush\3 0\4/g; $script =~ s/(\(\s*gimp-progress-init\s+\S+)(\s*\))/\1 -1\2/g; $script =~ s/(\(\s*gimp-text-get-extents)(\s+\S+){9}(\s*\))/\1\2 \"*\" \"*\"\3/g; $script =~ s/(\(\s*gimp-text)(\s+\S+){15}(\s*\))/\1 \"*\" \"*\"\2/g; $script =~ s/(\(\s*gimp-text-get-extents)(\s+\S+){9}(\s*\))/\1 \"*\" \"*\"\2/g; $script =~ s/(\(\s*plug-in-blur-randomize)((\s+\S+){5})/\1\2 10 0/g; $script =~ s/(\(\s*plug-in-map-object)((\s+\S+){12})(\s*\))/\1\2 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 \3/g; #Finish checking from plug-in-nova $script =~ s/(\(\s*)plug-in-randomize(\s+\S+\s+\S+\s+\S+)(\s+1)(\s+\S+\s+\S+)(\s*\))/\1plug-in-randomize-hurl\2\4\5 FALSE 0\6/g; $script =~ s/(\(\s*)plug-in-randomize(\s+\S+\s+\S+\s+\S+)(\s+2)(\s+\S+\s+\S+)(\s*\))/\1plug-in-randomize-pick\2\4\5 FALSE 0\6/g; $script =~ s/(\(\s*)plug-in-randomize(\s+\S+\s+\S+\s+\S+)(\s+3)(\s+\S+\s+\S+)(\s*\))/\1plug-in-randomize-slur\2\4\5 FALSE 0\6/g; } if ($from_version < 20 && $to_version >= 20) { #Replace deprecated constants with the name of a current constant foreach $old_constant (keys(%constants_2_0)) { #To avoid an incorrect match, check for white space or a bracket #before and after the constant to ensure we don't falsely match #a portion of some other constant. $script =~ s/([(\s]*)$old_constant([)\s]*)/\1$constants_2_0{$old_constant}\2/g; } #Add two extra arguments (reverse, and dither) $script =~ s/(\(\s*)gimp-blend(\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+)(\s+\S+\s+\S+\s+\S+)/\1gimp-edit-blend\2 FALSE\3 FALSE/g; #Remove image argument from gimp-image-(add|remove)-layer-mask $script =~ s/(\(\s*)gimp-image-(add|remove)-layer-mask(\s+\S+)(\s+\S+\s+\S+)/\1gimp-layer-\2-mask\4/g; #Add extra argument (edgemode) $script =~ s/([(\s]*plug-in-edge\s+\S+\s+\S+\s+\S+\s+\S+\s+[-\w]+)(\s*\))/\1 0\2/g; #The first search/replace should be used to set randomize parameter to TRUE #or FALSE based on the value of the parameter but it will make it harder to #do other updates to this procedure. Assume a random seed is always wanted. # $script =~ s/(\(\s*plug-in-blur-randomize)((\s+\S+){5})(\s+)(\S+)(\s+\S+)/\1\2\3 (= \4 10)\5/g; $script =~ s/(\(\s*plug-in-blur-randomize)((\s+\S+){5})(\s+\S+)(\s+\S+)/\1\2TRUE\4/g; #Replace deprecated 1.2 functions with the equivalent 2.0 function foreach $old_function (keys(%functions_2_0)) { #Include white space after function name to avoid an incorrect match. $script =~ s/([(\s]*)$old_function([)\s]*)/\1$functions_2_0{$old_function}\2/g; } } if ($from_version < 22 && $to_version >= 22) { #(plug-in-blur-randomize 1 img fire-layer 2 80 rndamt) #GIMP 2.1.0: blur.c, version 1.62, Wed Jun 16 15:40:56 2004 UTC #plug-in-blur-randomize was renamed to plug-in-blur #and randomize and repeat options were removed. $script =~ s/(\(\s*)gimp-brushes-(get|set)-spacing/\1gimp-brush-\2-spacing (car (gimp-context-get-brush))/g; $script =~ s/(\(\s*gimp-flip\s+\S+\s+\S+)/gimp-drawable-transform-flip-simple\1 TRUE 0.0 TRUE/g; $script =~ s/(\(\s*)gimp-gradients-sample-(custom|uniform)/\1gimp-gradient-get-\2-samples (car (gimp-context-get-gradient))/g; $script =~ s/(\(\s*)gimp-perspective(\s+\S+)(\s+\S+)((\s+\S+){8})/\1gimp-drawable-transform-perspective-default\2\4\3 TRANSFORM-RESIZE-ADJUST/g; $script =~ s/(\(\s*)gimp-rotate(\s+\S+)(\s+\S+)(\s+\S+)/\1gimp-drawable-transform-rotate-default\2\4 TRUE 0 0\3 TRANSFORM-RESIZE-ADJUST/g; $script =~ s/(\(\s*)gimp-scale(\s+\S+)(\s+\S+)((\s+\S+){4})/\1gimp-drawable-transform-scale-default\2\4\3 TRANSFORM-RESIZE-ADJUST/g; $script =~ s/(\(\s*)gimp-shear(\s+\S+)(\s+\S+)((\s+\S+){2})/\1gimp-drawable-transform-shear-default\2\4\3 TRANSFORM-RESIZE-ADJUST/g; $script =~ s/(\(\s*)gimp-transform-2d(\s+\S+)(\s+\S+)((\s+\S+){7})/\1gimp-drawable-transform-2d-default\2\4\3 TRANSFORM-RESIZE-ADJUST/g; $script =~ s/(\(\s*)script-fu-copy-visible(\s+\S+)(\s+\S+)(\s+\S+)/\1gimp-edit-copy-visible\3/g; $script =~ s/(\(\s*)script-fu-selection-round((\s+\S+){3})/\1script-fu-selection-rounded-rectangle\2 FALSE/g; $script =~ s/(\(\s*)plug-in-blur-randomize(\s+\S+\s+\S+\s+\S+)(\s+\S+\s+\S+\s+\S+\s+\S+)/\1plug-in-blur\2/g; #Finish mapping for gimp-text to gimp-text-fontname #Last 8 parameters need to be turned in to a fontname string # $script =~ s/([(\s])gimp-text((\s+\S+){9})(\s*\))/\1gimp-text-fontname\2\3/g; #Finish mapping for gimp-text-get-extents to gimp-text-get-extents-fontname #Last 8 parameters need to be turned in to a fontname string # $script =~ s/([(\s])gimp-text-get-extents((\s+\S+){3})(\s*\))/\1gimp-text-get-extents-fontname\2\3/g; #Replace deprecated 2.0 functions with the equivalent 2.2 function foreach $old_function (keys(%functions_2_2)) { #Include white space after function name to avoid an incorrect match. $script =~ s/([(\s]*)$old_function([)\s]*)/\1$functions_2_2{$old_function}\2/g; } } if ($from_version < 24 && $to_version >= 24) { #Remove calls to verbose as that function no longer exists. $script =~ s/\(\s*verbose[\s]*[\S]*[\s]*\)//g; #Replace deprecated 2.2 functions with the equivalent 2.4 function foreach $old_function (keys(%functions_2_4)) { #Include white space after function name to avoid an incorrect match. $script =~ s/([(\s]*)$old_function([)\s]*)/\1$functions_2_4{$old_function}\2/g; } } if ($from_version < 26 && $to_version >= 26) { #Replace deprecated 2.4 functions with the equivalent 2.6 function foreach $old_function (keys(%functions_2_6)) { #Include white space after function name to avoid an incorrect match. $script =~ s/([(\s]*)$old_function([)\s]*)/\1$functions_2_6{$old_function}\2/g; } } if ($from_version < 28 && $to_version >= 28) { #Replace deprecated 2.6 functions with the equivalent 2.8 function foreach $old_function (keys(%functions_2_8)) { #Include white space after function name to avoid an incorrect match. $script =~ s/([(\s]*)$old_function([)\s]*)/\1$functions_2_8{$old_function}\2/g; } } print "$script";