Index: /gs3-extensions/structured-image/trunk/CREATE-VENV-PYTHON3.sh
===================================================================
--- /gs3-extensions/structured-image/trunk/CREATE-VENV-PYTHON3.sh	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/CREATE-VENV-PYTHON3.sh	(revision 36247)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+source ./setup.bash
+
+if [ ! -d "$GEXT_STRUCTURED_IMAGE_INSTALLED/virtualenv-python3" ] ; then
+    python3 -mvenv "$GEXT_STRUCTURED_IMAGE_INSTALLED/virtualenv-python3"
+else
+    echo "" >&2
+    echo "!!!!" >&2
+    echo "! VirtualEnv Python3 already exists: $GEXT_STRUCTURED_IMAGE_INSTALLED/virtualenv-python3" >&2
+    echo "!!!!" >&2
+    echo "" >&2
+    echo "" >&2
+fi
+
+echo "****"
+echo "* To activate this version of python, enter:" 
+echo "*   source \"$GEXT_STRUCTURED_IMAGE_INSTALLED/virtualenv-python3/bin/activate\""
+echo "*"
+echo "* Then install the following Python module(s) with:"
+echo "*   pip install pyannote"
+echo "****"
+
+
Index: /gs3-extensions/structured-image/trunk/DEVEL-TOP-LEVEL.sh
===================================================================
--- /gs3-extensions/structured-image/trunk/DEVEL-TOP-LEVEL.sh	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/DEVEL-TOP-LEVEL.sh	(revision 36247)
@@ -0,0 +1,8 @@
+
+# Symlink this file so it is in the top-level Greenstone3 directory area
+
+source ./SETUP.sh
+
+source ./gs3-devel.sh
+
+
Index: /gs3-extensions/structured-image/trunk/README.txt
===================================================================
--- /gs3-extensions/structured-image/trunk/README.txt	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/README.txt	(revision 36247)
@@ -0,0 +1,34 @@
+#====
+# Getting the extension
+#====
+
+Assuming you are in the Greenstone3 top-level (i.e. GSDL3SRCHOME) directory,
+(if not already done so) this extension can be checked out as follows:
+
+  svn co https://svn.greenstone.org/gs3-extensions/structured-image/trunk ext/structured-image
+
+Note that the plugin this extension introduces makes use of a Google Service Account and requires credentials. For more details, visit: https://cloud.google.com/vision/docs/setup.
+
+
+#====
+# Compiling the extension
+#====
+
+#-<>
+#  <One-time-only>
+#--
+
+cd ext/structured-image
+./CREATE-VENV-PYTHON3.sh
+cd ../..
+
+ln -s ext/structured-image/SETUP-TOP-LEVEL.sh SETUP.sh
+ln -s ext/structured-image/DEVEL-TOP-LEVEL.sh DEVEL.sh
+
+# If your python does not already have Google Cloud Vision
+source ./SETUP.sh
+pip install --upgrade google-cloud-vision
+
+#--
+#  </One-time-only>
+#</>
Index: /gs3-extensions/structured-image/trunk/SETUP-TOP-LEVEL.sh
===================================================================
--- /gs3-extensions/structured-image/trunk/SETUP-TOP-LEVEL.sh	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/SETUP-TOP-LEVEL.sh	(revision 36247)
@@ -0,0 +1,64 @@
+
+_full_pyver_=$(python3 -V 2>&1 | grep -Po '(?<=Python )(.+)')
+_majorminor_pyver_=${_full_pyver_%.*}
+
+# Symlink this file so it is in the top-level Greenstone3 directory area
+
+source ./gs3-setup.sh
+
+function check_pip_installed()
+{
+    if [ ! -d "$GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python3/lib/python${_majorminor_pyver_}/site-packages/$1" ] \
+	&& [ ! -f "$GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python3/lib/python${_majorminor_pyver_}/site-packages/$1.py" ] ; then
+	echo "!!!!" >&2
+	echo "! Failed to find directory or file: " >&2
+	echo "!   $GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python3/lib/python${_majorminor_pyver_}/site-packages/$1(.py)" >&2
+	echo "!!!!" >&2
+	echo "! You need to: " >&2
+	if [ "x$VIRTUAL_ENV" = "x" ] ; then
+	    echo "!   source $GEXT_STRUCTURED_AUDIO/$GSDLOS/virtualenv-python3/bin/activate" >&2
+	    echo "! Then: " >&2
+	fi
+
+	if [ "$1" = "pyannote" ] ; then
+	    echo "! pip install https://github.com/pyannote/pyannote-audio/archive/develop.zip" >&2
+	else
+	    echo "!   pip install $1" >&2
+	fi
+	
+	echo "!" >&2
+	echo "!!!!" >&2
+	
+	return 1
+    fi
+}
+
+function check_pip_installed_all()
+{
+    for pkg in wheel pyannote speechbrain ; do
+	check_pip_installed $pkg
+	if [ $? != 0 ] ; then
+	    return 1
+	fi
+    done
+}
+
+
+if [ "x$VIRTUAL_ENV" = "x" ] ; then
+
+    echo ""
+    echo "****"
+    echo "* Activating Python v3 Virtual Env "
+    echo "****"
+    echo ""
+
+    source $GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python3/bin/activate
+
+fi
+
+
+check_pip_installed_all
+    
+if [ $? != 0 ] ; then
+    return 1
+fi    
Index: /gs3-extensions/structured-image/trunk/bin/script/vision.py
===================================================================
--- /gs3-extensions/structured-image/trunk/bin/script/vision.py	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/bin/script/vision.py	(revision 36247)
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+
+from cgitb import enable
+import os, argparse, json
+from pathlib import Path
+
+parser = argparse.ArgumentParser()
+parser.add_argument('inputfile', help="Image file to be processed")
+parser.add_argument('outputfile', nargs="?", help="Output file (.json, optional)")
+parser.add_argument('--credentials', nargs="?", help="Google application credential file (.json)") # credentials obtained from https://cloud.google.com/vision/docs/setup#sa-create
+# parser.add_argument('--credentials', nargs="?", help="Google application credential file (.json)", default="atea-storage-cd63a39dfeb5.json")
+parser.add_argument('--enable_image_labelling', action="store_true", help="") # enables image labelling / annotations
+parser.add_argument('--enable_image_ocr', action="store_true", help="") # enables ocr for images
+parser.add_argument('--enable_document_ocr', action="store_true", help="") # enables ocr for documents
+
+args = parser.parse_args()
+
+fileName = getattr(args, "inputfile")
+outputFile = getattr(args, "outputfile")
+gCreds = getattr(args, "credentials")
+enable_image_labelling = getattr(args, "enable_image_labelling")
+enable_image_ocr = getattr(args, "enable_image_ocr")
+enable_document_ocr = getattr(args, "enable_document_ocr")
+
+if (gCreds != None): # if creds not supplied, assume environment var is already set
+    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = gCreds; 
+
+p = Path(fileName)
+if (outputFile == None): # replace file extension with .csv if output file not defined
+    outputFile = p.with_suffix(".json")
+
+def detect_text(path):
+    # detects text/objects in image
+    from google.cloud import vision
+    from google.protobuf.json_format import MessageToDict
+    import io
+
+    print(" ---- Running Cloud Vision API ---- ")
+    client = vision.ImageAnnotatorClient()
+
+    with io.open(path, 'rb') as image_file:
+        content = image_file.read()
+
+    image = vision.Image(content=content)
+
+    if (enable_image_labelling): 
+        response = client.label_detection(image=image) # response obj
+    elif (enable_image_ocr):
+        response = client.text_detection(image=image) # response obj
+    elif (enable_document_ocr):
+        response = client.document_text_detection(image=image) # response obj
+
+    # print(response)
+
+    # https://stackoverflow.com/questions/52169264/vision-api-how-to-get-json-output 
+    texts = MessageToDict(response._pb) # converts protobuf to dictionary (potentially a cleaner solution exists?)
+
+    # https://stackoverflow.com/questions/16291358/python-saving-json-files-as-utf-8
+    with open(outputFile, 'w', encoding='utf8') as f:
+        json.dump(texts, f, ensure_ascii=False)
+
+    print("output written to " + str(outputFile))
+
+    if response.error.message:
+        raise Exception(
+            '{}\nFor more info on error messages, check: '
+            'https://cloud.google.com/apis/design/errors'.format(
+                response.error.message))
+
+detect_text(fileName)
Index: /gs3-extensions/structured-image/trunk/devel.bash
===================================================================
--- /gs3-extensions/structured-image/trunk/devel.bash	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/devel.bash	(revision 36247)
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+_full_pyver_=$(python3 -V 2>&1 | grep -Po '(?<=Python )(.+)')
+_pyver_=${_full_pyver_%%.*}
+
+if [ "x$_pyver_" = "x" ]  ; then
+    echo "" >&2
+    echo "Failed to establish the full version of python" >&2
+    echo "Defaulting to version 3" >&2
+    _pyver_=3
+fi
+    
+
+if [ "x$GEXT_STRUCTURED_AUDIO" = "x" ] ; then
+  source ./setup.bash
+fi
+
+if [ ! -f "$GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python$_pyver_/bin/activate" ] ; then
+    echo "" >&2
+    echo "!!!!" >&2
+    echo "! Failed to find:" >&2
+    echo "!   $GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python$_pyver_/bin/activate" >&2
+    echo "!" >&2
+    echo "! Have you run:" >&2
+    echo "!   ./CREATE-VEN-PYTHON$_pyver_.sh" >&2
+    echo "!" >&2
+    echo "! Followed by:" >&2
+    echo "!   source $GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python$_pyver_/bin/activate" >&2
+    echo "!!!!" >&2
+    echo "" >&2
+
+    # Uncomment the following if you want to stop everything immediately
+    #
+    # While it is commented out, it means the issue is flagged, but 
+    # allows for the circumstance that the developer is (for some reason)
+    # needing to make use of a version of python outside of this extension's area
+    # 
+    # return 1
+
+elif [ "$VIRTUAL_ENV" != "$GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python$_pyver_" ] ; then
+    # A python virtual env is in play, but not the one for Python v$_pyver_ in this extension's area
+    echo ""
+    echo "****"
+    echo "* Warning: VIRTUAL_ENV points to different location to the one in $GEXT_STRUCTURED_AUDIO"
+    echo "*   VIRTUAL_ENV      = $VIRTUAL_ENV"
+    echo "*   Extension's python$_pyver_ = $GEXT_STRUCTURED_AUDIO_INSTALLED/virtualenv-python$_pyver_"
+    echo "****"
+    echo ""
+fi
+
+export GEXT_STRUCTURED_AUDIO_DEVEL=1
+    
+
Index: /gs3-extensions/structured-image/trunk/perllib/plugins/GoogleVisionImagePlugin.pm
===================================================================
--- /gs3-extensions/structured-image/trunk/perllib/plugins/GoogleVisionImagePlugin.pm	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/perllib/plugins/GoogleVisionImagePlugin.pm	(revision 36247)
@@ -0,0 +1,262 @@
+######################################################################
+#
+# GoogleVisionImagePlugin.pm -- plugin that extends the capability of 
+# ImagePlugin to use Google Vision API allowing for: metadata labelling
+# of objects within a scene; OCR text recognition.
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 1999 New Zealand Digital Library Project
+#
+# 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.
+#
+###########################################################################
+
+package GoogleVisionImagePlugin;
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+no strict 'subs';
+
+use gsprintf;
+use FileUtils;
+
+use ImagePlugin;
+use BaseMediaConverter;
+
+use utf8;
+use JSON qw( from_json );
+
+sub BEGIN {
+    @GoogleVisionImagePlugin::ISA = ('ImagePlugin', 'BaseMediaConverter');
+}
+
+my $arguments =
+    [ { 'name' => "enable_image_labelling",
+	'desc' => "{GoogleVisionImagePlugin.enable_image_labelling}",
+	'type' => "flag",
+	'reqd' => "no" },
+    { 'name' => "enable_image_ocr",
+	'desc' => "{GoogleVisionImagePlugin.enable_image_ocr}",
+	'type' => "flag",
+	'reqd' => "no" },
+    { 'name' => "enable_document_ocr",
+	'desc' => "{GoogleVisionImagePlugin.enable_document_ocr}",
+	'type' => "flag",
+	'reqd' => "no" }
+];
+
+my $options = { 'name'     => "GoogleVisionImagePlugin",
+		'desc'     => "{GoogleVisionImagePlugin.desc}",
+		'abstract' => "no",
+		'inherits' => "yes",
+		'args'     => $arguments };
+
+sub new {
+    my ($class) = shift (@_);
+    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
+    push(@$pluginlist, $class);
+
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
+    new BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
+    my $self = new ImagePlugin($pluginlist, $inputargs, $hashArgOptLists);
+
+    return bless $self, $class;
+}
+
+sub begin {
+    my $self = shift (@_);
+    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
+
+    if ($self->{'enable_image_ocr'} && $self->{'enable_document_ocr'}) {
+        print STDERR "Please use the following command syntax for vision types: (--enable_image_ocr | --enable_document_ocr) [--enable_image_labelling]\n";
+        print STDERR "\t\t --enable_image_ocr : optical character recognition for text within images\n";
+        print STDERR "\t\t --enable_document_ocr : optical character recognition for text within documents\n";
+        print STDERR "\t\t --enable_image_labelling : annotation labeling for objects within images\n";
+        exit(2);
+    }
+
+    $self->SUPER::begin(@_);
+}
+
+sub vision_monitor_line {
+    my ($line) = @_;
+    
+    my $had_error = 0;
+    my $generate_dot = 0;
+        
+    if ($line =~ m/^.*$/) 
+    {
+        $generate_dot = 1;
+    }
+
+    return ($had_error,$generate_dot);
+}
+
+sub run_convert {
+    my $self = shift (@_);
+    my ($base_dir,$filename,$file,$doc_obj) = @_;
+    
+    my $section = $doc_obj->get_top_section();
+    
+    my $verbosity = $self->{'verbosity'};
+    my $outhandle = $self->{'outhandle'};
+    print $outhandle "----- GoogleVisionImagePlugin run_convert -----\n";
+    # print STDERR "*****", $self->{'enable_document_ocr'}, "\n";
+
+    my @vision_type = (); # array containing target ocr / labelling type(s)
+
+    if ($self->{'enable_image_labelling'}) { push(@vision_type, "enable_image_labelling"); } 
+    if ($self->{'enable_image_ocr'}) { push(@vision_type, "enable_image_ocr"); }
+    if ($self->{'enable_document_ocr'}) { push(@vision_type, "enable_document_ocr"); } 
+
+    my $vision_type_length = @vision_type; # assigning scalar var to array returns length
+
+    if ($vision_type_length != 0) {
+       
+        $self->init_cache_for_file($filename);
+        my $cached_image_dir = $self->{'cached_dir'};
+	    # my $audio_root = $self->{'cached_file_root'};
+
+        # my $filename_no_path = &File::Basename::basename($filename);
+
+        my $ofile = "google-vision-output.json";
+        my $ofilename = &FileUtils::filenameConcatenate($cached_image_dir,"google-vision-output.json");
+        my $collect_dir = $ENV{'GSDLCOLLECTDIR'};
+        my $credentials_filename = &FileUtils::filenameConcatenate($collect_dir, "etc", "atea-storage-cd63a39dfeb5.json");
+
+        if ($vision_type_length == 1) {
+            my $vision_type_first = $vision_type[0];
+            my $vision_cmd = "vision.py --$vision_type_first --credentials \"$credentials_filename\" \"$filename\" \"$ofilename\"";
+
+            $self->run_vision($file, $filename, $ofile, $ofilename, $vision_cmd, $vision_type_first, $section, $doc_obj);
+        } elsif ($vision_type_length == 2) {
+            my $vision_type_first = $vision_type[0];
+            my $vision_type_second = $vision_type[1];
+
+            my $ofilename_first = &FileUtils::filenameConcatenate($cached_image_dir, $vision_type_first . "-google-vision-output.json");
+            my $ofilename_second = &FileUtils::filenameConcatenate($cached_image_dir, $vision_type_second . "-google-vision-output.json");
+
+            my $vision_cmd_1 = "vision.py --$vision_type_first --credentials \"$credentials_filename\" \"$filename\" \"$ofilename_first\"";
+            my $vision_cmd_2 = "vision.py --$vision_type_second --credentials \"$credentials_filename\" \"$filename\" \"$ofilename_second\"";
+
+            $self->run_vision($file, $filename, $ofile, $ofilename_first, $vision_cmd_1, $vision_type_first, $section, $doc_obj);
+            $self->run_vision($file, $filename, $ofile, $ofilename_second, $vision_cmd_2, $vision_type_second, $section, $doc_obj);
+        } 
+    }
+
+    return "json";
+}
+
+sub run_vision {
+    use Data::Dumper;
+    my $self = shift (@_);
+    my ($file, $filename, $ofile, $ofilename, $vision_cmd, $vision_type, $section, $doc_obj) = @_;
+
+    my $vision_regenerated;
+    my $vision_result;
+    my $vision_error;
+
+    my $print_info = { 'message_prefix' => "GoogleVisionAPI",
+        'message' => "Sending $file to GoogleVisionAPI using vision.py" };
+
+    ($vision_regenerated,$vision_result,$vision_error)
+        = $self->run_cached_general_cmd($vision_cmd,$filename,$ofilename,$print_info);
+
+    $doc_obj->associate_file($ofilename,$vision_type . $ofile,"application/json",$section);
+
+    my $json_text = do { # read in json file
+        open(my $json_fh, "<:encoding(UTF-8)", $ofilename)
+            or die("Can't open \"$ofilename\": $!\n");
+        local $/;
+        <$json_fh>
+    };
+
+    my $cursection = $doc_obj->get_top_section(); # get top section for text append
+    
+    my $decoded_json = from_json($json_text); 
+    my $ocr_text;
+    if ($vision_type eq "enable_document_ocr" || $vision_type eq "enable_image_ocr") {
+        $ocr_text = $decoded_json->{textAnnotations}[0]{description}; # access full ocr content
+        $doc_obj->add_utf8_text( $cursection, $ocr_text); # append text to section
+
+        my $blocks = $decoded_json->{fullTextAnnotation}{pages}[0]{blocks};
+        my %text_and_language;
+
+        foreach my $block (@{ $blocks }) {
+            foreach my $paragraph (@{ $block->{paragraphs} }) {
+                foreach my $word (@{ $paragraph->{words} }) {
+                    my $detected_language = $word->{property}{detectedLanguages}[0]{languageCode} || "no_lang";
+                    my $word_text = "";
+                    foreach my $letter (@{ $word->{symbols} }) {
+                        $word_text .= $letter->{text};
+                    }
+                    $text_and_language{$detected_language} .= $word_text . " "; 
+                }
+            }
+        }
+        for (keys %text_and_language) {
+            $doc_obj->add_utf8_metadata ($cursection, "z_" . $_, $text_and_language{$_});
+        }
+
+
+    } elsif ($vision_type eq "enable_image_labelling") {
+        $ocr_text = $decoded_json->{labelAnnotations}; 
+        foreach my $label (@{ $ocr_text }) {
+            # write to metadata : 'description'='Book' 'score'='0.9' 'topicality'='0.9' 'mid'='/m/0123'
+            $doc_obj->add_utf8_metadata ($cursection, "description", $label->{description});
+            $doc_obj->add_utf8_metadata ($cursection, "score", $label->{score});
+            $doc_obj->add_utf8_metadata ($cursection, "topicality", $label->{topicality});
+            $doc_obj->add_utf8_metadata ($cursection, "mid", $label->{mid});
+            # write to metadata : 'descriptions'='Book' 'Book_score'='0.9' 'Book_topicality'='0.9' 'Book_mid'='/m/0123' 
+            $doc_obj->add_utf8_metadata ($cursection, "descriptions", $label->{description});
+            $doc_obj->add_utf8_metadata ($cursection, $label->{description} . "_score", $label->{score});
+            $doc_obj->add_utf8_metadata ($cursection, $label->{description} . "_topicality", $label->{topicality});
+            $doc_obj->add_utf8_metadata ($cursection, $label->{description} . "_mid", $label->{mid});
+
+        }
+    }
+}
+
+# do plugin specific processing of doc_obj
+sub process {
+    my $self = shift (@_);
+    # options??
+    my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
+
+    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
+    my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
+    my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'});
+    
+    $self->run_convert($base_dir,$filename_full_path,$url_encoded_filename,$doc_obj);
+    
+    $self->SUPER::process(@_);
+}
+
+1;
+
+
+
+
+
+
+
+
+
+
+
Index: /gs3-extensions/structured-image/trunk/setup.bash
===================================================================
--- /gs3-extensions/structured-image/trunk/setup.bash	(revision 36247)
+++ /gs3-extensions/structured-image/trunk/setup.bash	(revision 36247)
@@ -0,0 +1,59 @@
+
+extdesc="the Structured Image Extension"
+
+full_setup=`pwd`/${BASH_SOURCE}
+fulldir=${full_setup%/*}
+fulldir=${fulldir%/.}
+
+if [ "x$GSDLHOME" = "x" ] ; then
+  if [ -e ../../gs3-setup.sh ] ; then
+    export gsopt_noexts=1 && pushd ../.. && source ./gs3-setup.sh && popd 
+    export gsopt_noexts=
+  elif [ -e ../../setup.bash ] ; then
+    export gsopt_noexts=1 && pushd ../.. && source ./setup.bash && popd 
+    export gsopt_noexts=
+  else
+    # backstop
+    GSDLOS=`uname -s | tr '[A-Z]' '[a-z]'`
+    # check for running bash under cygwin
+    if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then
+      GSDLOS=windows
+    fi 
+
+  fi
+fi
+
+if [ "x$GEXT_STRUCTURED_IMAGE" = "x" ] ; then
+  export GEXT_STRUCTURED_IMAGE=$fulldir
+  export GEXT_STRUCTURED_IMAGE_INSTALLED=$GEXT_STRUCTURED_IMAGE/$GSDLOS
+
+  export PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/bin:$GEXT_STRUCTURED_IMAGE/bin/script:$PATH
+
+  if [ "x$LD_LIBRARY_PATH" = "x" ] ; then
+    export LD_LIBRARY_PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/lib
+  else
+    export LD_LIBRARY_PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/lib:$LD_LIBRARY_PATH
+  fi
+  if [ "x$DYLD_LIBRARY_PATH" = "x" ] ; then
+    export DYLD_LIBRARY_PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/lib
+  else
+    export DYLD_LIBRARY_PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/lib:$DYLD_LIBRARY_PATH
+  fi
+ if [ "x$PKG_CONFIG_PATH" = "x" ] ; then
+    export PKG_CONFIG_PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/pkgconfig
+  else
+    export PKG_CONFIG_PATH=$GEXT_STRUCTURED_IMAGE_INSTALLED/pkgconfig:$PKG_CONFIG_PATH
+  fi
+
+  extdir=${GEXT_STRUCTURED_IMAGE##*/}
+
+  if [ "x$GSDLEXTS" = "x" ] ; then
+    export GSDLEXTS=$extdir
+  else 
+    export GSDLEXTS=$GSDLEXTS:$extdir
+  fi
+
+  echo "+Your environment is now setup for $extdesc"
+else
+  echo "+Your environment is already setup for $extdesc"
+fi
