1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Liquify in Gimp (In 5 steps!)

Discussion in 'Gimp Tips & Tutorials' started by Rod, Feb 8, 2011.

  1. Rod

    Rod Moderator Staff Member

    Joined:
    Apr 19, 2010
    Messages:
    1,740
    Likes Received:
    0
    Trophy Points:
    36
    For those of you who want a bigger preview and somewhat better liquify tool than IWARP - this tutorial is for you.
    Note: This is for Windows users only
    If you can get Paint Dot Net to work in any other platform than you can probably do this also.But as far as i know PDN only works with Microsoft Frame Works, so good luck with that.
    This Python Module was originaly written by Rob A to call XnView for PS filters as Gimp-2.6.11 seems to have lost it's way with PSPI plug-in.That is to say many 8bf's fail in the new version of Gimp, and XnView handles all of them nicely.

    The Python Module has been edited by me to call Paint Dot Net instead.
    Paint Dot Net uses user submitted plug-ins and filters just like Gimp does, and its also free source.

    What you will need -
    Download Paint Dot Net here with Microsoft Frame Work - <a class="postlink" href="http://www.getpaint.net/download.html" onclick="window.open(this.href);return false;">http://www.getpaint.net/download.html</a>
    The Python-Fu setup for Gimp(Note: Not needed if you use the partha builds!) - <a class="postlink" href="http://www.gimpusers.com/tutorials/install-python-for-gimp-2-6-windows" onclick="window.open(this.href);return false;">http://www.gimpusers.com/tutorials/inst ... -6-windows</a>
    The Python Module (The script you can find below)

    The setup is well worth it if you want to use all of PDN's filters in Gimp.

    What the module does -
    This python module takes the current layer or new from layer and transfers it to Paint Dot Net, where you can use any filter on it there and it will save and import back to Gimp after editing in PDN. (more explanation on that to follow)

    So here is the tutorial - edited by Maffe to make it a little easier to follow.
    If you have ANY questions PM me and ill help you out. :)

    ENJOY!

    *****************************************************************
    A Python file Rob A created to call XnView, that now calls Paint Dot Net instead - Because i wanted a nice Liquify tool.

    1)
    First off you have to have a Windows operation system.
    - Windows XP - Confirmed by Owl700
    - Vista - Confirmed by Maffe811
    - Windows 7 - Not confirmed


    For 64-bit you can use Partha's portable versions of 2.7, but it is available in both 32-bit and 64-bit!
    The Partha versions also comes with python built in, so you dont' have to worry about the next step.

    And you need Python installed, if you haven't read this!

    2)
    You have to have Paint . Net installed as well as Microsoft.net framework.
    The paint dot net comes with that installer already so no need to hunt it down.

    3)
    Then you have to go to paint dot nets plug-in area and grab the Liquify filter or you can download this zip.
    It has a lot of other cool filters included with liquify

    4)
    Install it in Paint dot net. use the auto filter installer here
    <a class="postlink" href="http://forums.getpaint.net/index.php?app=core&module=attach&section=attach&attach_id=3910" onclick="window.open(this.href);return false;">http://forums.getpaint.net/index.php?ap ... ch_id=3910</a>
    Or just unzip the package of filters to the effects folder in the paint dot net directory under Program Files.
    (C:\Program Files\Paint.NET\Effects)

    5)
    Then grab this file Paint.NETShell.py by righ clicking and "save link as..." Make sure its saved as a .py file
    The code lays in a spoiler below if the link goes bad.
    In that case:
    - Open a text editor
    - Paste the code
    - Save as Paint.NETShell.py
    - Place it in your Plug-ins folder (C:\Users\*Your username*\.gimp-2.6\plug-ins)
    In Gimp you will find the plugin under Filters/Call/PaintDotNet



    How to use it
    Restart Gimp
    Create or open an image you want to liquify
    Run the script Filters/Call/Paint Dot Net
    Paint dot net will open with your temp image loaded
    Run the liquify tool/filter under effects/tools
    Click the close button on Paint Dot net
    The filter script will ask you if you want to save the changes to the temp Gimp file choose yes.
    The script will then close paint dot net, export the new image layer back to Gimp and place it as a new layer on top. :)

    Code in here incase link goes down:
    Code:
    #!/usr/bin/env python
    
    '''
    Paint.NETShell.py
    Call Paint.Net to allow use of Paint.Nets filters.  Windows Only.
    
    Author:
    Rob Antonishen
    
    Version:
    0.3 Fixed to work with filters that change alpha
    
    this script is modelled after the mm extern LabCurves trace plugin 
    by Michael Munzert http://www.mm-log.com/lab-curves-gimp
    
    
    License:
    
    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; version 3 of the License.
    
    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.
    
    The GNU Public License is available at
    http://www.gnu.org/copyleft/gpl.html
    
    '''
    
    from gimpfu import *
    import shlex
    import subprocess
    import os, sys
    import tempfile
    
    def plugin_main(image, drawable, visible):
      pdb.gimp_image_undo_group_start(image)
      
      # Copy so the save operations doesn't affect the original
      if visible == 0:
        # Save in temporary.  Note: empty user entered file name
        temp = pdb.gimp_image_get_active_drawable(image)
      else:
        # Get the current visible
        temp = pdb.gimp_layer_new_from_visible(image, image, "Visible")
        image.add_layer(temp, 0)
    
      buffer = pdb.gimp_edit_named_copy(temp, "PaintDotNETShellTemp")
    
      #save selection if one exists
      hassel = pdb.gimp_selection_is_empty(image) == 0
      if hassel:
        savedsel = pdb.gimp_selection_save(image)
    	
      tempimage = pdb.gimp_edit_named_paste_as_new(buffer)
      pdb.gimp_buffer_delete(buffer)
      if not tempimage:
        raise RuntimeError
      pdb.gimp_image_undo_disable(tempimage)
    
      tempdrawable = pdb.gimp_image_get_active_layer(tempimage)
    
      # Use temp file names from gimp, it reflects the user's choices in gimp.rc
      # change as indicated if you always want to use the same temp file name
      tempfilename = pdb.gimp_temp_name("png")
      #tempfilename = os.path.join(tempfile.gettempdir(), "Inkscapetempfile.png")
      
    
      # !!! Note no run-mode first parameter, and user entered filename is empty string
      pdb.gimp_progress_set_text ("Saving a copy")
      pdb.file_png_save_defaults(tempimage, tempdrawable, tempfilename, tempfilename)
    
      # Command line - Change to match where you installed XnView
      command = "\"C:\\Program Files\\Paint.NET\\PaintDotNet.exe\" \"" + tempfilename + "\""
      args = shlex.split(command)
    
      # Invoke external command
      pdb.gimp_progress_set_text ("run PaintDotNET...")
      pdb.gimp_progress_pulse()
      child = subprocess.Popen(args, shell=False)
      child.communicate()
    
      # put it as a new layer in the opened image
      try:
        newlayer2 = pdb.gimp_file_load_layer(tempimage, tempfilename)
      except:
        RuntimeError
      tempimage.add_layer(newlayer2,-1)
      buffer = pdb.gimp_edit_named_copy(newlayer2, "PaintDotNETShellTemp")
    
      if visible == 0:
        sel = pdb.gimp_edit_named_paste(drawable, buffer, 1)
      else:
        sel = pdb.gimp_edit_named_paste(temp, buffer, 1)
    	
      pdb.gimp_buffer_delete(buffer)
      pdb.gimp_edit_clear(temp)	
      pdb.gimp_floating_sel_anchor(sel)
    
      #load up old selection
      if hassel:
        pdb.gimp_selection_load(savedsel)
        image.remove_channel(savedsel)
      
      # cleanup
      os.remove(tempfilename)  # delete the temporary file
      gimp.delete(tempimage)   # delete the temporary image
    
      # Note the new image is dirty in Gimp and the user will be asked to save before closing.
      pdb.gimp_image_undo_group_end(image)
      gimp.displays_flush()
    
    
    register(
            "python_fu_paintdotnetshell",
            "Call PaintDotNET",
            "Call PaintDotNET",
            "Rob Antonishen",
            "Copyright 2011 Rob Antonishen",
            "2011",
            "<Image>/Filters/Call/PaintDotNET...",
            "RGB*, GRAY*", 
            [ (PF_RADIO, "visible", "Layer:", 1, (("new from visible", 1),("current layer",0)))
            ],
            [],
            plugin_main,
            )
    
    main()
    
    I know it seems like a lot to go through just for Liquify, but you will also get all the other PDN effects with it. ;)
     
  2. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    Re: Liquify in Gimp

    Okay, ive got this to work on Vista (32bit) and it works great! ;D
    Now, i think the reason it doesnt work on 64bit is a problem in the script... or that i use 32 bit gimp and 32 bit python... but i didnt think it would matter wich version i used...

    But... i dont know!
    ive done everything i did on the Vista machine and that works great, but when i click the script in gimp it doesnt work on the 64bit machine...
    when i think about it... it could be win 7 :p

    Is XP confirmed?
    Is there anyone here that can test this on Win 7 32bit ?

    But should we link the direct links to the Python and Pygtk ?
     
  3. Owl700

    Owl700 New Member

    Joined:
    Jan 27, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Re: Liquify in Gimp

    I am just a beginner, and managed to get everything working in XP. ;D

    I downloaded and followed the directions for installing Python from here:
    <a class="postlink" href="http://www.gimpusers.com/tutorials/install-python-for-gimp-2-6-windows" onclick="window.open(this.href);return false;">http://www.gimpusers.com/tutorials/inst ... -6-windows</a>
    I installed Paint and followed your tutorial.
    Everything works like a charm!
    Thanx for the help
     
  4. Willy

    Willy Member

    Joined:
    Mar 26, 2011
    Messages:
    746
    Likes Received:
    0
    Trophy Points:
    16
    Occupation:
    High School, Engineering Program
    Location:
    Michigan
    Home Page:
    Re: Liquify in Gimp

    Why exactly is this using MyPaint.net? Is there something I missed during my short time using it?
     
  5. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    Re: Liquify in Gimp

    Photoshop has liquify.
    Gimp has iWarp.
    Gimp's iWarp window is tiiiiiiiiiiiiiiiiiiiiiiiiinyyyyyyyyyyyyy!!!!!
    Now gimp uses a paint.net liquify addon wich is full screen like photoshop's!

    Its all just to get bigger editing area... Cause gimp's editing area...
    Its to small to do any good... Thats what she said ;D

    Gimp(Tiny window):
    [​IMG]

    PS(full screen):
    [​IMG]
     
  6. Willy

    Willy Member

    Joined:
    Mar 26, 2011
    Messages:
    746
    Likes Received:
    0
    Trophy Points:
    16
    Occupation:
    High School, Engineering Program
    Location:
    Michigan
    Home Page:
    Re: Liquify in Gimp

    Sup with her face, and thanks now I understand
     
  7. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    Re: Liquify in Gimp

    Idk, found the image on google :p
     
  8. Willy

    Willy Member

    Joined:
    Mar 26, 2011
    Messages:
    746
    Likes Received:
    0
    Trophy Points:
    16
    Occupation:
    High School, Engineering Program
    Location:
    Michigan
    Home Page:
    Re: Liquify in Gimp

    She has a very large eye... Maybe it is... omg Rebbeca Black?
     
  9. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    Re: Liquify in Gimp

    yeah, that was liqufy can do... :p
     
  10. Rod

    Rod Moderator Staff Member

    Joined:
    Apr 19, 2010
    Messages:
    1,740
    Likes Received:
    0
    Trophy Points:
    36
    Re: Liquify in Gimp

    Glad to hear you all got it working okay. :)
    The nice thing about this script is you can add other programs to the python script and Gimp will run any of them.
    My list so far

    XNView
    ASCII Gen
    Anamorphe Me
    Photo Shop CS5
    Imagelys
    MS Paint
    Deep Paint
    Inkscape
    PaintDOTNet
    MyPaint
    Photo Filter Factory,
    Photo Pos Pro
    Java mosaic
    Java Image Editor
    Vector Magic
    Photo Clinic

    So as you can see Gimp was given quite a bit of power with this script.
    Rob A is a genius. :)
     
  11. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    Re: Liquify in Gimp

    Thats awsome!!! :p
     
  12. Rod

    Rod Moderator Staff Member

    Joined:
    Apr 19, 2010
    Messages:
    1,740
    Likes Received:
    0
    Trophy Points:
    36
    Re: Liquify in Gimp

    Has anyone gotten it to work in 64 bit yet?
    It should work if the Paint Dot Net and Gimp are both 64 bit.
    I wonder if i could get someone at GimpChat.com with Parthas version of 2.7.3 64 bit Gimp to test it? :)
    As i am pretty darn sure Gimp-2.6.11 does not come with a 64 bit install.
     
  13. Maffe811

    Maffe811 The forum pet Staff Member

    Joined:
    Jul 2, 2009
    Messages:
    6,813
    Likes Received:
    2
    Trophy Points:
    38
    Location:
    Norway/Norge/Norwegen
    Re: Liquify in Gimp

    I don't remeber... :p
    Il download and test even tough im supposed to be in bed! :p

    Edit:
    It finished up extracting the files, so i poped the script in the corect folder and started partha-gimp.
    It sucessfully called paint.net after i tweaked the path in the script(not sure if that is needed though).
    I forgot the paint.net plug-ins but they aren't the important part.

    I edited the first post and added that it worked.
    Please check my spelling as it is 1:15 am :p *YAWN*
    5 hours and 45 minutes with sleep if i go to bed now :p
     

Share This Page