Skip to content

Commit

Permalink
Upgrade gimp3 API calls (from GIMP_PROC_ARG to gimp_procedure_add)
Browse files Browse the repository at this point in the history
- API still not stable and changed after last commit. Upgrade fix-ca calls.
- Import Anders Jonsson's gimp2 Swedish translation into metainfo file.
- rpmlint en_US spelling of traveling (not en_CA travelling).
- better choice to re-point rpm spec URL to use /archive/%version/
  • Loading branch information
JoesCat committed Sep 5, 2024
1 parent be191ab commit 6e13c72
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
choiceL: [--disable-silent-rules, --enable-silent-rules --enable-debugtime]
choiceL: [--disable-silent-rules, --enable-silent-rules, --enable-debugtime]
steps:
- uses: actions/checkout@v3
- name: Create configure
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
GIMP3-Fix-CA is a [GIMP](http://www.gimp.org/) plug-in to correct Chromatic Aberration
(CA). For a general explanation about Chromatic Aberration, you can find information
from [Wikipedia](http://en.wikipedia.org/wiki/Chromatic_aberration).
GIMP3-Fix-CA can fix Lateral CA colored fringing caused by light travelling through
lenses, and Directional CA caused by light travelling through dense material such as
GIMP3-Fix-CA can fix Lateral CA colored fringing caused by light traveling through
lenses, and Directional CA caused by light traveling through dense material such as
glass or water.

GIMP2-Fix-CA was written by Kriang Lerdsuwanakij [email protected], and
Expand Down Expand Up @@ -177,7 +177,7 @@ The picture below shows (50% zoom) corrected image of the interested region.
## Download and building GIMP3-Fix-CA

Fortunately, everything is in just one file. Just get the C source file.
To compile and install the plug-in, you need the development library
To compile and install the plug-in, you need the development library
for Gimp. Usually it's in gimp-devel package in your distribution.
Use the command
```sh
Expand All @@ -195,9 +195,9 @@ instead. (use the Installation method below for other OSes). Type
```
for further help.

If Gimp is already running in your system, exit and restart Gimp for the new
If GIMP3 is already running in your system, exit and restart Gimp for the new
plug-in to be detected. The following displays GIMP3-Fix-CA information from
the GIMP menu.
the GIMP3 menu.

![](img-fix-ca/plug-in-browser.png)

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ AC_PROG_CC
AC_PROG_SED
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_CHECK_PROGS([GIMPTOOL],[gimptool-3.0 gimptool-2.99],[:])
AC_PATH_PROG([STRIP],[strip],[:])
AC_PATH_PROG([GIMPTOOL],[gimptool-3.0],[:])
AC_PATH_PROG([MSGFMT],[msgfmt],[:])
AC_PATH_PROG([MSGINIT],[msginit],[:])
AC_PATH_PROG([MSGMERGE],[msgmerge],[:])
Expand Down
99 changes: 54 additions & 45 deletions fix-ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>


#ifdef GDK_WINDOWING_QUARTZ
#import <Cocoa/Cocoa.h>
#elif defined (G_OS_WIN32)
Expand All @@ -56,12 +55,9 @@
#endif

#define PLUG_IN_PROC "plug-in-fix-ca"
#define PLUG_IN_ROLE "gimp-fix-ca"
#define PLUG_IN_ROLE "gimp3-fix-ca"
#define PLUG_IN_BINARY "fix-ca"

#define PROCEDURE_NAME "Fix-CA"
#define DATA_KEY_VALS "fix_ca"

/* For fixca() row buffer management */
#define SOURCE_ROWS 120
#define INPUT_MAX SOURCE_ROWS/4
Expand Down Expand Up @@ -198,42 +194,54 @@ fixca_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_documentation (procedure,
/* menu entry tooltip blurb */ _("Fix Chromatic Aberration"),
/* help for script developers */ _("Fix Chromatic Aberration caused by "
"optical lens (eg: analog cameras, adapters)."
"This plugin works by shifting red and blue" "pixels in the specified amounts."),
"optical lens (eg: analog cameras, adapters). "
"This plugin works by shifting red and blue " "pixels in the specified amounts."),
/* help ID */ PLUG_IN_PROC);
gimp_procedure_set_attribution (procedure,
/* author(s) original, GIMP3 */ "Kriang Lerdsuwanakij, Jose Da Silva",
/* copyright */ "GPL3+",
/* date made */ "2024");

GIMP_PROC_ARG_DOUBLE (procedure, "bluel",
_("_Blue-L"), _("Blue amount (lateral)"),
-INPUT_MXF, INPUT_MXF, 0.0, G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "redl",
_("_Red-L"), _("Red amount (lateral)"),
-INPUT_MXF, INPUT_MXF, 0.0, G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "lensx",
_("Lens_X"), _("Lens center X (lateral)"),
-1, GIMP_MAX_IMAGE_SIZE-1, -1, G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "lensy",
_("Lens_Y"), _("Lens center Y (lateral)"),
-1, GIMP_MAX_IMAGE_SIZE-1, -1, G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "interpolation",
_("_Interpolation"),
_("Interpolation 0=None/1=Linear/2=Cubic"),
0, 2, 1, G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "bluex",
_("B_lue-X"), _("Blue amount, X axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0, G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "redx",
_("R_ed-X"), _("Red amount, X axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0, G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "bluey",
_("Bl_ue-Y"), _("Blue amount, Y axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0, G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "redy",
_("Re_d-Y"), _("Red amount, Y axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0, G_PARAM_READWRITE);
gimp_procedure_add_double_argument (procedure, "bluel",
_("_Blue-L"), _("Blue amount (lateral)"),
-INPUT_MXF, INPUT_MXF, 0.0,
G_PARAM_READWRITE);
gimp_procedure_add_double_argument (procedure, "redl",
_("_Red-L"), _("Red amount (lateral)"),
-INPUT_MXF, INPUT_MXF, 0.0,
G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "lensx",
_("Lens_X"), _("Lens center X (lateral)"),
-1, GIMP_MAX_IMAGE_SIZE-1, -1,
G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "lensy",
_("Lens_Y"), _("Lens center Y (lateral)"),
-1, GIMP_MAX_IMAGE_SIZE-1, -1,
G_PARAM_READWRITE);
gimp_procedure_add_int_argument (procedure, "interpolation",
_("_Interpolation"),
_("Interpolation 0=None/1=Linear/2=Cubic"),
0, 2, 1, G_PARAM_READWRITE);
gimp_procedure_add_double_argument (procedure, "bluex",
_("B_lue-X"),
_("Blue amount, X axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0,
G_PARAM_READWRITE);
gimp_procedure_add_double_argument (procedure, "redx",
_("R_ed-X"),
_("Red amount, X axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0,
G_PARAM_READWRITE);
gimp_procedure_add_double_argument (procedure, "bluey",
_("Bl_ue-Y"),
_("Blue amount, Y axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0,
G_PARAM_READWRITE);
gimp_procedure_add_double_argument (procedure, "redy",
_("Re_d-Y"),
_("Red amount, Y axis (directional)"),
-INPUT_MAX, INPUT_MAX, 0.0,
G_PARAM_READWRITE);
}

return procedure;
Expand Down Expand Up @@ -382,17 +390,17 @@ fixca_run (GimpProcedure *procedure,
}
#ifdef DEBUG_TIME
printf("Xsize=%d Ysize=%d, ",
fix_ca_params.Xsize, fix_ca_params.Ysize);
fix_ca_params.Xsize, fix_ca_params.Ysize);
printf("bytes per pixel=%d, bytes per color=%d\n",
fix_ca_params.bpp, fix_ca_params.bpc);
fix_ca_params.bpp, fix_ca_params.bpc);
#endif

/* prepare to draw, or preview, fetch values and image */
sizeImg = fix_ca_params.Xsize * fix_ca_params.Ysize * fix_ca_params.bpp;
fix_ca_params.srcImg = g_new (guchar, sizeImg);
fix_ca_params.destImg = g_new (guchar, sizeImg);
if (fix_ca_params.srcImg == NULL || fix_ca_params.destImg == NULL) {
/* TODO: REDO gimp-fix-ca to work with super-large-pics */
/* TODO: REDO gimp3-fix-ca to work with super-large-images */
if (fix_ca_params.destImg != NULL) g_free(fix_ca_params.destImg);
if (fix_ca_params.srcImg != NULL) g_free(fix_ca_params.srcImg);
g_set_error (&error, GIMP_PLUG_IN_ERROR, 0,
Expand Down Expand Up @@ -422,7 +430,7 @@ fixca_run (GimpProcedure *procedure,
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) {

#ifdef DEBUG_TIME
double sec;
double sec;
struct timeval tv1, tv2;
gettimeofday (&tv1, NULL);

Expand Down Expand Up @@ -747,6 +755,7 @@ fixca_dialog (GimpProcedure *procedure,
//g_object_unref (fixcaparams);

#else
// this is similar to GIMP2, v2.10 code
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *combo;
Expand Down Expand Up @@ -1081,18 +1090,18 @@ saturate(guchar *dest, gint width,
gint bpp, gint bpc, gdouble s_scale)
{
GimpRGB rgb;
GimpHSV hsv;
GimpHSL hsl;
gint b = absolute (bpc);
dest += b; /* point to green before looping */
while (width-- > 0) {
rgb.r = get_pixel (dest-b, bpc);
rgb.g = get_pixel (dest , bpc);
rgb.b = get_pixel (dest+b, bpc);
gimp_rgb_to_hsv (&rgb, &hsv);
hsv.s *= s_scale;
if (hsv.s > 1.0)
hsv.s = 1.0;
gimp_hsv_to_rgb (&hsv, &rgb);
gimp_rgb_to_hsl (&rgb, &hsl);
hsl.s *= s_scale;
if (hsl.s > 1.0)
hsl.s = 1.0;
gimp_hsl_to_rgb (&hsl, &rgb);
set_pixel (dest-b, rgb.r, bpc);
set_pixel (dest , rgb.g, bpc);
set_pixel (dest+b, rgb.b, bpc);
Expand Down
10 changes: 8 additions & 2 deletions org.gimp.extension.fix3-ca.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<description>
<p xml:lang="C">
This extension helps the user correct Lateral Chromatic Aberration (CA) due
to different color wavelengths travelling through a lens, or Directional CA,
to different color wavelengths traveling through a lens, or Directional CA,
where the amount of CA is assumed to be the same throughout the image due to
light travelling through dense material such as glass or water.
light traveling through dense material such as glass or water.
</p>
<p xml:lang="es">
Esta extensión ayuda a corregir la aberración cromática lateral (CA) debido
Expand All @@ -31,6 +31,12 @@
ou CA direcional, onde a quantidade de CA é considerada a mesma em toda a
imagem devido a luz viajando através de materiais densos, como vidro ou água.
</p>
<p xml:lang="sv">
Denna insticksmodul hjälper användaren korrigera lateral kromatisk aberration
(CA) orsakad av att färger av olika våglängd passerar genom en lins, eller
direktionell CA där mängden CA antas vara densamma i hela bilden på grund av
att ljus passerar genom material såsom glas eller vatten.
</p>
</description>
<url type="homepage">https://github.com/JoesCat/gimp3-fix-ca</url>
<url type="help">https://github.com/JoesCat/gimp3-fix-ca#readme</url>
Expand Down
27 changes: 14 additions & 13 deletions rpm/gimp3-fix-ca.spec.in
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
#
# spec file for package gimp3-fix-ca plugin
#
%define moname gimp30-fix-ca
%define plugindir %{_libdir}/gimp/3.0/plug-ins/fix-ca
%define moname gimp30-fix-ca
%define plugindir %{_libdir}/gimp/3.0/plug-ins/fix-ca

Name: @FIX_CA_PACKAGE_NAME@
Version: @FIX_CA_VERSION@
Release: 0
Summary: A Gimp3 plugin for correcting Chromatic Aberration (CA)
License: GPLv3+
Group: Graphics/Editors and Converters
Group: Productivity/Graphics/Bitmap Editors
URL: https://github.com/JoesCat/gimp3-fix-ca
Source0: https://github.com/JoesCat/gimp3-fix-ca/releases/download/%{version}/%{name}-%{version}.tar.gz
Source0: https://github.com/JoesCat/gimp3-fix-ca/archive/%{version}/%{name}-%{version}.tar.gz

BuildRequires: autoconf
BuildRequires: automake
BuildRequires: gcc
BuildRequires: make
BuildRequires: gettext-devel
BuildRequires: gtk+3-devel
BuildRequires: pkgconfig(gimp-3.0)
BuildRequires: gettext-devel
BuildRequires: pkgconfig(gtk+-3.0)
BuildRequires: pkgconfig(gimp3)

Requires: gimp3


%description
A Gimp3 plug-in to correct Chromatic Aberration (CA).
GIMP3-Fix-CA can fix Lateral CA caused due to light travelling through lenses,
and fix Directional CA due to light travelling through dense material
A GIMP3 plug-in to correct Chromatic Aberration (CA).
GIMP3-Fix-CA can fix Lateral CA caused due to light traveling through lenses,
and fix Directional CA due to light traveling through dense material
such as glass or water.


%prep
%setup -q

%build
autoreconf -i
automake --add-missing
autoreconf --force --install --verbose
%configure
%make_build

Expand All @@ -48,6 +49,6 @@ automake --add-missing
%files -f %{moname}.lang
%license COPYING
%{plugindir}/fix-ca
%{_datarootdir}/metainfo/org.gimp.extension.fix3-ca.metainfo.xml
%{_datadir}/metainfo/org.gimp.extension.fix3-ca.metainfo.xml

%changelog

0 comments on commit 6e13c72

Please sign in to comment.