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条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?