After quite a few downloads and some trial and error, I was able to
eventually get my new plug-in to compile successfully. After adding a UI to
specify the threshold settings, and perhaps a bit more performance tweaking
I will plan to submit it for public evaluation. Just how you go about doing
that I don't know yet, but hopefully I can find some web pages to give me a
Meanwhile, for the record I wanted to try to document the basic steps that I
used to make this process work. Hopefully this may be somewhat useful to
others. I am working under MS Windows 2K, with MS Visual C++ 5.0. Steps as
1. Download and install the Windows installer binary gimp and GTK+ images
off of the links from Jernej Simoncic's page at
http://www2.arnes.si/~sopjsimo/gimp/. After all, a gimp plug-in isn't much
good unless you've got gimp to run it with, right? Installation for both of
these was pretty simple and went off without a hitch. Thanks a lot for
providing these easy to install images!!!
2. Install MS VC++ 5.0. Can be tricky in and of itself, because v5.0 is
somewhat outdated now days. Had to reinstall MS Jet and MDAC from
www.microsoft.com/data after doing this to replace the obsolete versions
that VC 5.0 installed. Am worried that other obsolete gunk may have also
been installed, but couldn't specifically find anything else out of sync.
3. Download and unzip the following include and library packages from Tor
Lillqvist's downloads page at
4. Download and unzip the following source packages from Tor Lillqvist's
downloads page at http://www.gimp.org/~tml/gimp/win32/downloads.html (same
page as above): gimp-1.2.4-tml-20020907-src.zip
5. Fire up MS VC++ 5.0, and create a new Win32 project, noting the project
directory that is created.
6. Copy autocrop.c from the gimp-1.2.4\PLUG-INS\COMMON source subdirectory
to the project directory.
7. Copy config.h.win32 from the gimp-1.2.4 subdirectory to the project
directory and rename to config.h .
8. Copy glibconfig.h from the LIB\GLIB-2.0\INCLUDE glib subdirectory to the
9. Add each of the above files to my VC project via the RMB->Add Files to
Project... menu item.
10. Edit GTYPES.H in the INCLUDE\GLIB-2.0\GLIB glib subdirectory and change
the <glibconfig.h> reference to "glibconfig.h". That probably shouldn't
have been necessary, but I wasn't sure what other means would have been a
better approach to have the compiler locate glibconfig.h in another
directory. Moving glibconfig.h to the main glib include directory didn't
seem like the appropriate thing to do, since it includes
11. RMB Settings... on the project, change Setting For to All
12. On the C/C++ tab, Category: Preprocessor, add the paths for each of the
three include subdirectories of the previously downloaded packages to the
Additional include directories field (the glib include path ends in
13. On the Link tab, Category: Input, add gimp.lib, intl.lib, and
glib-2.0.lib to the Object/library modules, and add the paths for each of
the three lib subdirectories of the previously downloaded packages to the
Additional library path field.
14. Hit OK in the Project Settings window.
15. Select Build->Set Active Configuration from the VC menu, and select the
Win32 Release configuration then click OK.
16. Select Build->Build <projectname>.exe from the VC menu. Should build
with no warnings or errors. You've now successfully built a duplicate of
the autocrop plug-in.
17. Now copy autocrop.c to threshcrop.c (my new plug-in name), make some
desired changes in the code, and provide a new location for the plug-in in
the gimp menu structure by changing the approrpriate, easily recognizable
argument to gimp_install_procedure, and re-build. Oops, almost forgot to
mention that you need to go into Settings..., General tab for autocrop.c and
select Exclude from build to avoid problems with duplicate main(), etc.
18. Copy the <projectname>.exe file from your project directory to the
Program Files\GIMP\lib\gimp\1.2\plug-ins directory.
19. Fire up gimp and load an image. RMB on the image and if everything
worked right, then your new plug-in should be found in the gimp menu
structure where you placed it in step 17. Click on the menu item for the
plug-in, and it should execute, taking whatever action that it was intended
to perform. Mine is a minor modification to autocrop which does cropping
based on user-specified threshold values, rather than assuming that the
entire border area must have only a single color. My version is MUCH better
for scanned images. Still needs some minor additional development and
tweaking before I'll be ready to release it for general consumption though.
One problem that I ran into was how to debug my application. Not being a C,
Windows, and GIMP development guru, I wasn't sure how to do that since the
plug-in could not be executed directly under the control of the debugger, as
it must be executed by the gimp instead. Also, since the plug-in is a Win32
app, and not a console app, I didn't have any kind of console window to echo
debugging messages. I could have created a duplicate console app
specifically for debugging, but that would have required a duplicate VC
project with all of the same setup, and would have been somewhat of a minor
pain. So, what I did instead was really ugly: I used the text area of the
gimp progress indicator to display my debugging messages! That worked, but
was definitely painful, and not highly recommended.
Please note that I am NOT an experienced C developer. I wouldn't be
surprised if there were some other changes to project settings in VC that
might have been appropriate for performance, etc. Also, I specifically did
NOT download or install everything that might be necessary to build any
conceivable plugin. I only used that components that I specifically needed
for this particular project. So, other folks may have additional/better
suggestions, or you may need additional components besides those that I have
specified here. Hopefully though, at least this will give some of you a bit
of a starting point.
By the way, I did NOT use gimptool, or any other tools or make files, etc.
I don't know whether any of those might have made my task any easier or not.
I suspect not in this specific case, but that might be a completely
different story for a more complex plug-in.
Wanted to say thanks once again to Tor Lillqvist for all of the info and
files on his web site related to porting the gimp to Windows. Without that
I would have been completely stuck.
> ----- Original Message -----
> From: "Kevin Myers" <[EMAIL PROTECTED]>
> To: "gimp users" <[EMAIL PROTECTED]>
> Sent: Monday, October 14, 2002 10:23 AM
> Subject: [Gimp-user] Threshold Crop Plug-in
> > Hello,
> > I would like to develop (or preferably locate) a tool somewhat similar
> > the default gimp autocrop, but with this difference: It would allow you
> > specify a threshold range in some manner for the border that is to be
> > cropped. If it handles RGB that would be fine, but in my case all that
> > really care about is grayscale.
> > I've searched the gimp registry and didn't see anything similar, so I'm
> > considering writing one of my own by using the existing autocrop plug-in
> > a starting point. I've done some preliminary looking at the code and
> > written pseudo-code for the primary changes that would be needed.
> > I can't seem to locate any docs on what you actually need in order to
> > compile a plug-in...
> > In autocrop libgimp is the only external library that is used, and I
> > think that I need anything else either, at least for a simple initial
> > version with hardcoded threshold values and no user interface.
> > I would think that I can easily locate and download the header file(s)
> > libgimp. But I'm an inexperienced C developer, and don't know what else
> > anything that I may need. I will be mucking with tiff files, but since
> > itself will be doing all of the actual file interaction, I don't think
> > I should need libtiff or anything like that, right? Also, I don't need
> > libgimp source other than the header files, do I?
> > Finally, I will be doing my work under Windows. I have several
> > available, including a couple of versions of Microsoft Visual C++. I
> > want my plug-in to be dependent on Cygwin libraries or anything like
> > so I don't plan to use Cygwin for this development. By default (because
> > don't know any better) I was planning to MSVC++ 6.0 to write and compile
> > plug-in. Will this work? Are there any other tools that I am likely to
> > need in order to develop this extremely simple plug-in?
> > After compiling, I believe that all I should need to do to run the
> > is to locate it in the proper gimp subdirectory on my machine, right?
> > Thanks in advance for any tips.
> > Kevin M.
> > Round Rock, Texas
> > _______________________________________________
> > Gimp-user mailing list
> > [EMAIL PROTECTED]
> > http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user
> Gimp-developer mailing list
> [EMAIL PROTECTED]
Gimp-developer mailing list