GNOME Bugzilla – Bug 337888
Autocrop crops more than it should
Last modified: 2008-01-15 13:06:41 UTC
Please describe the problem: When an entire row or column of pixels are all the same color with other colors with fully transparent areas included, the area of full visibility at the edge of the image are cropped away when using autocrop. Steps to reproduce: 1. Create a new image of any size (like 320x240). 2. Create a new layer and have at least one row of all-white pixels (or any color) on the top. 3. Add a transparent row of pixels somewhere in the middle and pixels fully transparent. 4. Use layer > autocrop. Actual results: When using autocrop at the end, the row of white pixels disappears being cropped out until the part that is partially transparent. The area that is invisible (fully transparent) also gets cropped away, of which I expect. Expected results: I only expect the fully transparent areas (alpha of 0) to be cropped away leaving the white area alone, particularly with transparent layers. If not a transparent layer, the color to be cropped should be the background color from the color swatches. Does this happen every time? As far as I can tell, yes. Other information: I created a test XCF file as a sample that has this. Try using autocrop on the five test layers and see what happens. The four lower layers are cropped in a strange way and the top layer (test 5) is how it should behave, even if there were different colors colors around the border.
Created attachment 63079 [details] XCF test case Test the behavior of autocrop using the 5 test layers provided. The lower 4 test layers have strange behaviors but the top layer, test 5, works like it should.
I find this bug report very hard to understand, but I can see that something is indeed going wrong. I'm not sure about the rest, but if you take the attached xcf image, and set it so that just the layers "Background" and "test 1" are visible, then do "autocrop layer" on the "test 1" layer, you will see that a small area along the bottom edge, and a small area along the right edge, get cropped when they should not be.
Created attachment 70395 [details] two more examples Try autocropping either of the upper two layers; both get their rightmost column chopped, both have varying intensities along that column. Overzealousness only happens at the rightmost column for me -- if I duplicate the rightmost column at the next column to the left, still only the rightmost column is cropped. Repetetively autocropping it crops one duped column each time. Hopefully this will help.
Hm... an off by one error?
Now fixed in CVS (HEAD branch): 2006-08-16 Sven Neumann <sven@gimp.org> * plug-ins/common/autocrop.c (autocrop): fixed overzealousness when cropping on a drawable border (bug #337888).
I've copied the autocrop() method from the HEAD branch to gimp-2-2: 2006-08-16 Sven Neumann <sven@gimp.org> * plug-ins/common/autocrop.c: merged changes from HEAD branch. Fixes bug #337888 and other problems.