Step 1
Install GIMP 2.8.18 in the folder below by selecting custom install. For this tutorial GIMP was installed within;
C:\devtools\GIMP 2
Step 2
Launch PowerShell (run as an administrator) and navigate to the Python folder within GIMP installation
PS C:\Windows\system32> cd.. PS C:\Windows> cd.. PS C:\> cd .\devtools PS C:\devtools> cd '.\GIMP 2'
PS C:\devtools\GIMP 2> cd .\Python PS C:\devtools\GIMP 2\Python> ls Directory: C:\devtools\GIMP 2\Python Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 16/11/2016 09:26 DLLs d---- 16/11/2016 09:27 Lib -a--- 23/05/2015 11:40 26624 python.exe -a--- 23/05/2015 11:40 2459648 python27.dll -a--- 23/05/2015 11:40 27136 pythonw.exe
Step 3
Set the script execution policy to unrestricted, so that all download scripts can be run (Caution: any scripts you execute from this point onward are ran in unrestricted mode, only run trusted scripts)
Type Set-ExecutionPolicy Unrestricted in Powershell
PS C:\devtools\GIMP 2\Python> Set-ExecutionPolicy Unrestricted
Step 4
Make a directory for install scripts; for this tutorial we will include install scripts for pip and pillow.
Type mkdir install_scripts into Powershell
PS C:\devtools\GIMP 2\Python> mkdir install_scripts Directory: C:\devtools\GIMP 2\Python Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 16/11/2016 09:45 install_scripts
Step 5
Download install scripts. In PowerShell issue the following commands to download get-pip.py
(NOTE: make sure file destination folder already exists prior to running PowerShell command)
PS C:\devtools\GIMP 2\Python> (new-object System.Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:\devtools\GIMP 2\Python\install_scripts\get-pip.py')
After running this command get-pip.py file should be created as shown below.
Step 6 (Very Important Step!)
Verify that the correct version on Python is in use within GIMP by specifying path. Set path to the location of GIMP's Python installation by setting env:Path as show below.
PS C:\devtools\GIMP 2\Python> $env:Path = ".";;
Check modules already installed and then install pip. Launch python and note that version should be 2.7.10 (The error show below in the pygtk.pth will be addressed later)
PS C:\devtools\GIMP 2\Python> python Error processing line 3 of C:\devtools\GIMP 2\Python\lib\site-packages\pygtk.pth: Traceback (most recent call last): File "C:\devtools\GIMP 2\Python\lib\site.py", line 152, in addpackage exec line File "<string>", line 1, in <module> ImportError: No module named runtime Remainder of file ignored Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
Next check if the pygtk module is installed by typing help("modules") or to just list pygtk type the following;
>>> help("modules pygtk")
This will result in the following screen if successful. If its not listed check the GIMP 2.8.18 installing again.
Step 7
Install pip by issuing the following command in PowerShell (check location of get-pip.py file)
PS C:\devtools\GIMP 2\Python> .\python.exe 'C:\devtools\GIMP 2\Python\install_scripts\get-pip.py'
Install pillow by issuing the following command in PowerShell
PS C:\devtools\GIMP 2\Python> python -m pip install pillow
Start python shell and issue the following command in python shell to list installed PIL modules
>>> help("modules pil")
PIL installed modules will be listed
Step 8
To check that pillow is installed correctly launch python shell (GIMP's installed version). Place an image within the temp directory and make a copy using the following python code.
>>> from PIL import Image >>> im = Image.open("C:\\temp\\ProfilePicture.png") >>> im.save("C:\\temp\\copy.png") >>>
This should make a copy of the source image ProfilePicture.png and place within the same directory.
Next add hello_world.py plugin to GIMP plugins directory (see creating plugins post) , launch GIMP to verify setup.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from gimpfu import * from PIL import Image import datetime import sys def hello_world(): sys.stdout = open( 'c:\\temp\\out.txt', 'a') print(datetime.datetime.now()) print('Hello_World') pdb.gimp_message('Hello World !....') pdb.gimp_message('Producing Image!....') im = Image.open("C:\\temp\\ProfilePicture.png") # Place an image in an accessible folder im.save("C:\\temp\\copy_script.png") # Copy of image saved pdb.gimp_message('Image Produced.....') print('Finished processing') register( 'python-fu-hello-world', # Plugin unique name 'Hello World', # Tooltip short name 'This is a Hello World Plugin', # Tooltip long description 'Muddy Games', 'Muddy Games', '2016', # Creator, Copyright owner, released 'Hello World', # Menu name '*', # Supported image color * <all> [], # Input Parameters [], # Return Parameters hello_world, # Method to call menu='<Image>/Filters/Render') # Menu entry location main() |
If the plugin produced a file (copy_script.png) your environment is working correctly. If the script runs correctly you should see the following after File | New and Filter | Render | Hello World
Final Notes
PowerShell
To make it easier to install and check that plugins are running a Powershell Script (Source) be used. This script was tested on Windows 10 machine with PowerShell running as Administrator. On successful execution of the Powershell Script (Source) you should be able to use the 'Hello World' script via Filter | Render | Hello World as shown below;
Execute the script using the following command if script execution has been disabled;
powershell -ExecutionPolicy ByPass -File .\GIMP_Pillow_Scripting.ps1
Custom Script Locations
The file gimprc enables GIMP preferences. This file can be very useful for adding new locations for script plug-ins. The file can be edited with a text editor or via Edit | Preferences.
There are two locations for the file, the global file is located with GIMP # folder and the user specific file is located in users directory as shown below.
C:\Users\[Username]\.gimp-2.8
Add the following line to gimprc to make it a default location for your custom plugins
(plug-in-path "C:\\projects\\plug-ins")
Save the file and restart GIMP any custom plug-ins within the plug-in-path specified above should now be listed with GIMP.
Everyone needs to settle on a logo configuration organization which is the best and the best one is picked based on significant experience. logo design service
ReplyDelete