Tear-off

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
0
Average: 4.5 (6 votes)

Comments

Got there at last!

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.

Great!

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.

Some corrections for GIMP 2.6.8

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 :)

What locale do you use?

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.

Most of these are incorporated into version 0.2 thanks!

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

Great - Thank You

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!

Works with Gimp 2.6 under MacOSX

I found that Gimp 2.6.6 did not create a .gimp-2.6 directory in my home area under MacOS 10.5.7. So I did the following. Make a directory in your Mac home area: mkdir gimp-plug-ins (you could call it .gimp-2.6/plug-ins if you like and it won't show up in Finder.) Put the scrnshot_tearoff.py file in your new directory: cp scrnshot_tearoff.py ~/gimp-plug-ins Start Gimp and go to Edit->Preferences->Folders->Plug-ins Add a new plug-in folder. It's name will be something like /Users//gimp-plug-ins - use the Browse button on the directory chooser if you are unsure how to type this in. Restart Gimp and you should see the Tear Off item under the Image menu. Great plug-in. Works like a charm. Does exactly what I want. Thanks Ed.

Does not work

I need your help. I'm not so sure what you meant with "make a new directory in my home". So in Aiza (that's my home on my Mac OS X), I made a new folder --- gimp-2.6-plug-ins. Is that what you mean?

I want to use this python so much so please let me know how. Thanks!

Works with Gimp 2.6 under MacOSX - thanks!

You're welcome, and thank you very much for the MacOSX steps! Hopefully that will enable more people to use the plugin. Thanks, Ed. --- Edgar D'Souza (http://edgar.b.dsouza.googlepages.com/)

A couple comments on the code

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.

Thanks for the code tips

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/)

Superb

Fantastic script thanks - just what I was looking for!

very nice script

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

Thanks for the feedback!

Thanks for trying it out and letting me know it works! :-) Appreciate it. Regards, Ed. Edgar D'Souza (http://edgar.b.dsouza.googlepages.com/) === The gene pool could use a little chlorine.

.py format?

I can't install this script because it has a .py format. Aren't scripts supposed to be in .scm format? Please Help!

its written in python, not

its written in python, not scheme, which means that you will have to have python installed on your computer to have it work (with pygtk and others)

If you've installed on Windows, please tell me what's needed?

Hi, If you've gotten the script working under Windows, could you please tell me what extras must be installed to get it to work? I'm kicking myself for forgetting to mention 'install Python' (added it and PyGTK now, thanks to your pointer) - this is what comes of being a full-time Linux user :-) Thanks, Ed. Edgar D'Souza (http://edgar.b.dsouza.googlepages.com/)

Hi Dear, I've download &

Hi Dear, I've download & installed the all-in-one easy pack of Python mentioned above (with Window restart in mentioned place). Then I install the latest GIMP 2.6.6 > start GIMP > close GIMP > copy the "scrnshot_tearoff.py" to "C:\Documents and Settings\myname\.gimp-2.6\plug-ins" > start GIMP again > open an image. However, there is no "Tear off" item under the "Image" menu. So I try to download GIMP 2.6.1 from here: http://www.filehippo.com/download_the_gimp/4760/, and retry the procedure, but "Tear off" still doesn't appear. Do you have any suggestion on what I've been missed? Thank You.

I would love the answer to

I would love the answer to this as well. I'm having the same problem.

For those who may come later:

These instructions seemed to get me going, though I believe I actually downloaded later versions of a couple of these. Also don't forget to install/reinstall gimp after you've completed the other installations.

http://gimptricks.deviantart.com/gallery/#/d2kqm1b

Sad to hear you're having problems

Since other users appear to have gotten it working with (earlier versions of) GIMP under Windows, I am guessing that some change with the new version of GIMP may be the issue, as mentioned at: http://www.gimpusers.com/forums/gimp-user/10670-python-support.html Have you tried reinstalling GIMP 2.6.6 with the "custom" option, and in the following dialog checked the "python" checkbox - as mentioned in the above page? The page also mentions that pycairo, pygobject, and pygtk need to be the new versions (the post by Alec Burgess) - have you tried manually installing those? If you have tried all those, then does the Filters>Python-Fu>Console show up? If not, then there is probably still some issue with the Python installation (and its libraries), or perhaps with enabling Python support in GIMP 2.6.6. I regret that I don't use Windows, so I cannot try this out on my own computers to see if I could get it working. Regards Ed. Edgar D'Souza (http://edgar.b.dsouza.googlepages.com/)

It works on Windows

First, uninstall Gimp 2.6.6 and install Gimp 2.6.5. Gimp report that there is a problem with Python support for the Windows 2.6.6 version. Second, edit the .py file: add a comment (#) at the beginning of line 50 and un-comment line 52 to enable log writing. Then restart Gimp, open an image and find "Tear Off" at the bottom of the Image section. Works great! Thank you Ed.

Update needed for default log file name on Windows

Thank you for prodding me, and for spelling out what should've been obvious to me :-( namely that if the log filename wasn't changed, it would break the script. I have some free time, so I'm adding some code to try and determine whether the OS is Windows or Linux/POSIX and provide an appropriate default log filename... I hope to upload the fixed version soon. Thanks, Ed. --- Edgar D'Souza (http://edgar.b.dsouza.googlepages.com/)

Python support does work

Python support does work fine in 2.6.6. Where did you get the problem reports from?

It Works on 2.6.10 and 2.7.1

Just follow the directions:
edit the .py file: add a comment (#) at the beginning of line 50 and un-comment line 52 to enable log writing. Then restart Gimp, open an image and find "Tear Off" at the bottom of the Image section. Works great!

Thank you Ed.

Syndicate content