You are here

Tear-off

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!

As a technical editor/writer, I found the need for a plugin to easily crop application screenshots with that somewhat jagged "torn-off" appearance. I found a way to manually obtain the effect I needed, and simply replicated the steps in a Python script, using the gimpfu module.

===========================
07 Jul 2010: UPDATED to v 0.2 by Tracy S. Fitch -- now Windows 7-compatible, plus several other changes (changelog is below). A huge thank-you to Tracy for the major work, and for the major courtesy of sending the updated script to me to update this post!
===========================

To install the plugin:
1. Put the Python file (rename the v0.2 file to remove the annoying .txt extension that this site adds automatically) in the plug-ins folder in the GIMP settings folder in your home folder (or your user settings folder on Windows). That is, if you're using GIMP 2.6 under Linux, the folder would be ~/.gimp-2.6/plug-ins/. Under Windows, you could go to C:\Documents and Settings\\ and search for folders whose names contain "gimp", then go to the plug-ins folder under that.
2. Under Linux, make the file executable (chmod u+x scrnshot_tearoff.py). This is not required for Windows.
3. (Added thanks to comments) If you don't have Python and PyGTK installed, you'll need to install them. This is most likely to happen for Windows computers; many Linux distributions install Python by default. Head to http://www.python.org/download/ and http://www.pygtk.org/downloads.html for Windows installables; for Linux, use your distribution's package management tool to look for and install Python and PyGTK.
4. (Re)start GIMP.

The original plugin script puts a "Tear-off" menu item on the Image menu for all image windows only (that is, no menu option is available in the main GIMP Toolbox window's menus). Tracy's v0.2 has the menu option at Filters > Distort > Tear-off. Capture your screenshot, or open a saved image; select the area of the image that you want to keep; click the plugin's menu to get a dialog where you can modify the plug-in parameters.

This script should run in the following environments:
- Ubuntu Linux 7.10, 8.10, 9.04, 10.04 // Python 2.5.1 to 2.6.x// GIMP 2.4.2 to 2.6.8
- (from the comments) Mac OS X (10.5.7)
- (thanks to Tracy!) Windows 7, GIMP 2.6.9, Python 2.6.4, pygtk-2.16, pycairo-1.8.6, pygobject-2.20
- as per zemalf's comment, "Gimp 2.6.8 (with Windows XP & latest stuff, like GTK+bundle 2.18.7, pygtk 2.16, pyobject 2.20, pycairo 1.8.6)" with the changes listed in the comment.

Changelog for v0.2 (attachment filename scrnshot_tearoff_v0.2_TSF.py.txt :-/ ):
#Version: 0.2 2010-07-05 -- Tracy S. Fitch (thespian at bigfoot.com) -- Windows Compatible
# Known Issues:
# - still no real testing -- just one more platform:
# - Windows 7 (Version 6.1.7600)
# - GIMP 2.6.9
# - Python 2.6.4
# - pygtk-2.16
# - pycairo-1.8.6
# - pygobject-2.20
#
# Changes:
# - switched to current directory log file (should be Linux/Win safe)
# - divided logging into progress, debug, error, & none
# - added progress bar updates & pulses
# - moved menu path to a separate value in register statement
# - moved to filters->distorts since it seems similar to page curl
# - added optional border function (default on)
# - modified resizing after drop shadow to only add in the shadow direction
# - rearranged layers to put shadow on the bottom
# - linked shadow and border layers to the original image
# - optional merging of border and shadow layers (default on)
# - formatted dialog (to the extent I can figure out how to format gimpfu's dialog)

Footnote: if, like me, you have a vertically-challenged display (my laptop runs 1366x768 pixels) then the lower portion of the parameters dialog may "fall off" the screen. Under Linux, you can hold down Alt, click on any blank area of the dialog, and drag it up to view the rest of the dialog. Under Windows, Alt+Spacebar > Move, and hitting the Up arrow key several times, should do the trick. Unfortunately, the gimpfu method of creating plugins leaves little scope for making the dialog broader, not taller :-( Sorry.

AttachmentSize
scrnshot_tearoff_v0.2_TSF.py.txt26.87 KB
scrnshot_tearoff.py10.48 KB
GIMP Version: 
Code License: 

Comments

This works awesomely! Except one thing: With GIMP 2.8.3 on OSX 10.8.5 I got a permission error writing the log file. I just set the logging level to None by uncommenting line 82 tearoff_loglevel = 'None'. I didn't have time to figure out the permissions issue. With that change this worked great.

Took a while to find my way through the maze of information and get GIMP v 2.6.10 set up to accept Python Scripts. This is running on Windows XP.
Once that was accomplished the rest was relatively straight forward.
Thanks for a useful looking script.

Apparently comment #42 at http://www.gimpusers.com/tutorials/install-python-for-gimp-2-6-windows.html is by you, and you probably got to that page because of Tracy's link (via deviantart)... great, since now other WinXP (and other Windows versions) users have a tested resource to refer to!

Thanks,
Ed.

Thank you, this was exactly what I was looking for! However, I had to make some tweaks to make this work on Gimp 2.6.8 (with Windows XP & latest stuff, like GTK+bundle 2.18.7, pygtk 2.16, pyobject 2.20, pycairo 1.8.6)

Here are the corrections I made to get is working:

1. added 'gettext.install' below 'from gimpfu import *' (line 44 or so):

gettext.install("gimp20-python", gimp.locale_directory, unicode=True)

2. added two parameters below 'params_list = []' (line 198 or so):

params_list.append( (PF_IMAGE, "image", "Input image", None) )
params_list.append( (PF_DRAWABLE, "drawable", "Input drawable", None) )

3. added 'menu' and 'domain' after 'tearoff' on the register() (line 230 or so):

    tearoff

-->

    tearoff,
    menu="<Image>/Image/Te_ar-off",
    domain=("gimp20-python", gimp.locale_directory)

(and to get it to work on Windows made the "comment line 50", "uncomment/edit line 52" stuff too to get the log-file right)

I hope those help someone else too, since the script is awesome.

p.s. I don't know why these changes were needed, but since it wasn't working for me at first, I checked some other .py scripts that were working and copied like a ninja :)

Zemalf, what locale is in use on your system? I don't use Windows, so won't be able to try to debug your problem, but I'm guessing it's due to the system language settings on your system that you need to add the code you mention. Localization is still a black-box mystery for me, I'm afraid :-(

Thanks for your comment, and pardon me for the delayed response - I've now subscribed to the comments RSS feed, in Google Reader. Hopefully that will update me when a new comment is posted.

Regards,
Ed.

I know from some additional googlage that the addition of the separate explicit menu item in the register instruction means you have to explicitly add the additional two parameters you specified. Essentially, if you use the older style register that puts the path and the menu item name all together, gimpfu automatically add those two parameters. As soon as you use the newer style register that breaks out the menu path, then you have to list them for them to be included in the call.

I included the gettext.install instruction based on Zemalf's advice, though I didn't see it doing anything specifically for me. Like Ed, I presume it relates to localization issues that I haven't seen or tested.

--Tracy

I am not a graphic artist but am starting my own analytics consulting practice and trying to design my logo - was using PPT and have been messing around with GIMP for a week.

This plug-in is doing exactly what I wanted - thank you so much and all the above help was gret as well.

Cheers!

The PDB function 'gimp-edit-clear' can be used instead of cutting to a named buffer. Also, cutting the (contents of a) selection should not result in loss of the selection as stated in Comment 6A. My guess is that during your testing of this, you performed a Paste (an operation which would cause the selection to be forgotten) and then deleted the floating layer.

Saul, Thanks for the code tips. I'll try them out with my current GIMP 2.6 but am not sure if making the changes means it will stop working for GIMP 2.4... IIRC I'd tried gimp-edit-clear but it just didn't work for me then. I guess I can upload a separate script file with the changes, and that way people can download and try each. Thanks, Ed. Edgar D'Souza (http://edgar.b.dsouza.googlepages.com/)

Excellent Script - I like it very much - (I'm adding a screenshot)

Pages

Subscribe to Comments for "Tear-off"