Login

    Register

Managed Hosting

PROJECT CATEGORIES

 

ImageUtils
Project Home Known Issues Contact Project

ImageUtils Issue: TrimCanvas Tolerance doesn't work

Name: TrimCanvas Tolerance doesn't work
ID: 3
Project: ImageUtils
Type: Bug
Area: Code
Severity: Low
Status: Open
Related URL:
Creator: James Moberg
Created: 06/09/09 6:11 PM
Updated: 08/15/11 6:57 AM
Description: I'm using TrimCanvas() on a JPG that has top and bottom side whitespace ranging from FFFFFF to F5F5F5. I've tried adding the "tolerance" parameter and it only seems to work if the value is set to 255 at which point it generates an error (The rectangular crop area must not be empty).

None of the demo scripts I've seen use the tolerance parameter or use a JPG image as a starting point.
History: Created by Jamo (James Moberg) : 06/09/09 6:11 PM

Comment by nanoamp (Nick Kaijaks) : 08/15/11 6:57 AM
I know this is an old issue, but it sounds similar to what I've just found (in Railo). In the JPEGs I've been looking at, the background had a 'normalized' alpha of 0, instead of 255 as I'd expect. Solution was to replace the cfreturn of the ColorsAreEqual() method with:


      <cfset local.colorChannelsMatch = (Abs( ARGUMENTS.ColorOne.Red - ARGUMENTS.ColorTwo.Red ) LTE ARGUMENTS.Tolerance) AND
      (Abs( ARGUMENTS.ColorOne.Green - ARGUMENTS.ColorTwo.Green ) LTE ARGUMENTS.Tolerance) AND
      (Abs( ARGUMENTS.ColorOne.Blue - ARGUMENTS.ColorTwo.Blue ) LTE ARGUMENTS.Tolerance) />
      
      <!---
         Check that either alpha is within tolerance too,
         or (edge case) that one is binary opposite of the other (0 vs 255)
       --->
      <cfreturn local.colorChannelsMatch and (
         (Abs( ARGUMENTS.ColorOne.Alpha - ARGUMENTS.ColorTwo.Alpha ) LTE ARGUMENTS.Tolerance) OR
         (Abs( ARGUMENTS.ColorOne.Alpha - ARGUMENTS.ColorTwo.Alpha ) is 255)
      ) />

Seems

Comment by nanoamp (Nick Kaijaks) : 08/15/11 6:57 AM
*Seems to work for me!

To add a comment to this bug, please login using the link above.