Thanks for reporting this. Does the attached simpler patch fix the problem for you? Dividing by QuantumRange instead of multiplying by QuantumScale avoids potential double-rounding problems in future versions of ImageMagick.