Pick some fiexs from ImageMagick official repo
Backport from V7 branch