The wavelet/JPEG 2000 plug-in, written by Divyanshu Vats, from the 2006 GIMP Google Summer of Code wavelet project, mentored by Simon Budig.
It creates three plug-ins:
jp2: JPEG 2000 support
denoise: A noise removal plug-in
ihalf: Inverse halftoning -- remove halftones from printed images.
It requires the openjpeg library, available at: http://www.openjpeg.org/
I'm not sure what the license is (the code files don't say) but the COPYING file looks pretty free.
Attachment | Size |
---|---|
jp2.tar.gz | 989.86 KB |
Comments
plugin segfaults with openjpeg v1.2
plugin segfaults with openjpeg v1.2
The plugin is delivered with it's own copy of the openjpeg.h header.
The structures have changed, and certain things are much larger.
Remove the local openjpeg.h header, add the following to src/main.h:
#ifndef MAX_PATH
#define MAX_PATH
#endif
and the plug-in will build and not segfault.
My first rendered image was a bit ugly, but at least it didn't segfault...
JPEG2000 plugin and Linux
The license of this code is
The license of this code is unclear to me (COPYING is rather generic, and some of the source files do not contain any reference).
We should try to solve this.
plugin
JP2 save: rate variable not initialized
/* Get other parameters from interface */ parameters.numresolution = 6; rate = 0; dialog(&rate); parameters.tcp_rates[0] = rate;
The bug seems to be fixed (image size with zero rate seems to be almost the same size as my lossless test image), but I'm afraid I should have initialized the variable elsewhere, since I forgot almost everything about C... [Edited] I also noticed that if I wanted to type the JP2 extension in uppercase, the plugin would crash. So I added: static const char *extension[] = { "pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2", "jpt", "PGX", "PNM", "PGM", "PPM", "BMP", "J2K", "JP2", "JPT" }; Not very proud of this (if someone writes "Jp2", I suppose it will crash, too. As for the rate statement, I finally wrote: if (rate < 0 || rate > 100) rate = 0; But the slider always starts at zero, which proves that the variable is out of bounds every time the program starts. I retrieved my old C reference manual, mouldy, ill-smelling, dated 1990... [...later] I read one page of the ill-smelling manual, and I removed my uppercase constants. Just wrote:if (strnicmp (ext, extension[i], 3) == 0)
instead ofif (strncmp (ext, extension[i], 3) == 0)
Same issue in jp2read. Same remedy. The Linux source should be modified too:if (strncasecmp (ext, extension[i], 3) == 0)
Another small bug: if you try to save a multi-layer image, the error is not handled and the plugin crashes. François CollardDon't assume extension is always 3 characters
1. Much better to remove the length of the comparison completely, e.g. use 'strcasecmp', see http://www.opengroup.org/onlinepubs/000095399/functions/strcasecmp.html :
if ( strcasecmp(ext, extension[i]) == 0 )
2. If your windows compiler doesn't have strcasecmp, then it probably has stricmp (check your doco), so add this to a header file (which is #included by the module) somewhere:
#ifdef _WIN32
#define strcasecmp(a,b) stricmp((a),(b))
#endif
3. Finally, in your list of extensions, you can add "jpeg" - note that this is a 4-letter extension.
Plugin - questions