After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 443640 - Rescaling with Lanczos crashes GIMP
Rescaling with Lanczos crashes GIMP
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
2.3.x
Other All
: Normal critical
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2007-06-03 17:19 UTC by Yuu Yamaki
Modified: 2008-01-15 14:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed fix (1.13 KB, patch)
2007-06-04 16:08 UTC, Sven Neumann
none Details | Review
proposed fix, revised (1.13 KB, patch)
2007-06-05 18:08 UTC, Sven Neumann
committed Details | Review

Description Yuu Yamaki 2007-06-03 17:19:03 UTC
Steps to reproduce:
1. Image -> Scale Image
2. orig_width < dest_width && orig_height > dest_height
3. Interpolation method: lanczos
4. Press OK


Stack trace:
(Sorry, I don't provide stack trace, because I'm using FreeBSD and recompiling full GNOME libraries takes too many times and costs.)

------------------GIMP's outputs ---------------------------------
This is a development version of GIMP.  Debug messages may appear here.


Gimp-Paint-Funcs-ERROR **: file scale-funcs.c: line 258 (expand_line): should not be reached
aborting...
gimp-2.3: terminated: Abort trap: 6

(script-fu:57654): LibGimpBase-WARNING **: script-fu: wire_read(): error
------------------- end -------------------------------------------

Functions called as 
scale_region() -> get_scaled_row() -> expand_line()

Other information:
app/paint-funcs/scale-funcs.c
line: 445   if (interpolation == GIMP_INTERPOLATION_LANCZOS && orig_height <= height)
is false and goto line 490 then get_scaled_row() is called with GIMP_INTERPOLATION_LANCZOS
Comment 1 Sven Neumann 2007-06-04 13:11:52 UTC
This problem does not seem to be reproducible with current SVN. Please give a more detailed description with exact pixel dimensions.
Comment 2 Yuu Yamaki 2007-06-04 13:43:51 UTC
For example:
                 width x height
Original image:    800 x 800
Destination   :    801 x 799

or
                 width x height
Original image:    512 x 512
Destination   :    513 x 511

This bug was maybe fixed in svn.
I'll check svn.
Comment 3 Sven Neumann 2007-06-04 15:57:50 UTC
It is still reproducible with these values.
Comment 4 Sven Neumann 2007-06-04 16:08:35 UTC
Created attachment 89337 [details] [review]
proposed fix

This change fixes the crash. I am however not sure if it introduces other problems.
Comment 5 Yuu Yamaki 2007-06-05 12:20:50 UTC
+    case GIMP_INTERPOLATION_LANCZOS:
+      scale_region_lanczos (srcPR, destPR, progress_callback, progress_data);
+      break;

This "break" is "return", isn't it?
Comment 6 gg 2007-06-05 16:10:15 UTC
yes that would make more sense or else the same code will still get called with GIMP_INTERPOLATION_LANCZOS.

IIRC this test was put in by Geert since it was thought that lanczos was not a good choice for image reduction. I think the idea was that it falls back to cubic.

ie.


  if (interpolation == GIMP_INTERPOLATION_LANCZOS && orig_height <= height)
    {
      scale_region_lanczos (srcPR, destPR, progress_callback, progress_data);
      return;
    }
  else 
    {
     interpolation=GIMP_INTERPOLATION_CUBIC;
    }

I'm not sure if sneakily changing this behind the users back is the best choice but it's at least correct code.

I seem to remember suggesting about 9 mth back when this came up that a better way would be to modify the drop down list of interp types if there is a difference in the way the code handles this.

Unless that idea gets more support than it did last time the short term fix may be what Sven intended: to reinstate lanczos on reduction and let the decide if it's what he wants.

It will be different from cubic so it's better than a secret spec violation via an unnotified change of interp.

I'll try to run some tests on lanczos reducution later.

Comment 7 Sven Neumann 2007-06-05 17:50:44 UTC
The problem here is that you can't decide whether you are doing reduction or expansion because the user might expand the size in one direction and reduce it in the other. That's exactly the situation that causes the test to fail and GIMP to crash. It would be better if the Lanczos scaling code handled reduction.
Comment 8 Sven Neumann 2007-06-05 18:08:33 UTC
Created attachment 89424 [details] [review]
proposed fix, revised
Comment 9 gg 2007-06-05 20:48:25 UTC
well it can "handle" it but the results are different.

It has some of the blockiness of NONE but with less distortion than nearest neighbours rather crude interp.

Both linear and cubic give a smoother result but lanczos seems to be a lot closer to original colour contrast and brightness. Lin and cubic seem rather soft and less contrasty by comparison.

[The contrast issue should probably be looked at elsewhere since there seems to be a net difference between lin/cubic scaled 25% and original viewed at 25%, photo image.]


While lanczos produces very good results as a pixelisation filter, I'm still not convinced of validity of using an imperfect bandpass filter when scaling down an image since there should be no higher frequencies to filter out and all that is left is the ringing and the imperfections of the filter.

I dont see this so much as lanczos not handling this situation so much as it being an inappropriate filter to use on reduction.

Good point about possible opposed scaling factors. I'd overlooked that but it is conceivable that someone could want to make an image wider and shorter, esp. with factors close to 1:1

The effect of attempting this with lanczos should be ... interesting.

/gg
Comment 10 Sven Neumann 2007-06-05 20:59:05 UTC
The proposed patch is probably the best thing to do then. The code then does what the user asks it to do. Since we aren't proposing Lanczos as the default interpolation type, this should be fine. The user will get what they asked for and the crash should be fixed.
Comment 11 Sven Neumann 2007-06-06 11:55:10 UTC
I have committed this change then, with some additional code cleanups.

2007-06-06  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/scale-funcs.c (scale_region): always use
	scale_region_lanczos() for LANCZOS interpolation. Fixes bug #443640.