dpz90118 2012-10-25 23:26
浏览 269
已采纳

使用php中的imagefilter()使图像清晰

Is there any possibilities to make image more sharp using imagefilter() function? I am using imagettftext() which adds Anti-aliasing to fonts and the fonts looks bit de-focused. I like to make my final image bit sharpen so that I can reduce the blur around the char's in my image.

Different Test Images

  • Font used
    • Roboto-Thin.ttf
    • Roboto-Black.ttf

Image with light fonts

I like to have my fonts to look something like those lines next to it.

enter image description here

Image with dark fonts

enter image description here

Image with -$font_color (Some web resources suggested to make font colour value to negative which basically turns off the anti-aliasing) But in this case the fonts looks ugly. (Left-To-Right 100 is with turned off anti-aliasing)

enter image description here

  • 写回答

3条回答 默认 最新

  • douke1954 2012-10-25 23:39
    关注

    GD Solution

    $old = "old.png";
    $new = "new.png";
    
    $im = imagecreatefrompng($imgname);
    imagetruecolortopalette($im, FALSE, 256);
    imagecolorset($im, imagecolorclosest($im, 159, 159, 159), 0, 0, 0);
    imagecolorset($im, imagecolorclosest($im, 191, 191, 191), 0, 0, 0);
    
    imagepng($im, $new);
    imagedestroy($im);
    

    Image Magic Solution

    convert old.png -fuzz 0% -fill rgb(0,0,0) -opaque rgb(159,159,159) new.png
    convert new.png -fuzz 0% -fill rgb(0,0,0) -opaque rgb(191,191,191) new.png
    


    They would output

    enter image description hereenter image description here

                      Old                           new
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?