How to fill the text in ImageMagick with the right color.



  • We need to put the text in the right color in this picture.

    введите сюда описание изображения

    ImageMagick

    Doing it in such a way:

    convert -background transparent temp1.png \( -clone 0 -fill '#3e312b' -colorize 90% -draw "color 0,0 reset" \) -compose atop -composite temp.png
    

    But as a result, it's only the color of an external leash. If -background indicate not transparentAnd the right color of the bay. '#3e312b'It's all rectangled.

    введите сюда описание изображения

    Should be out like this (in gimp for the sample as it should be)

    введите сюда описание изображения

    P.S. I know that -fill '#3e312b' It is perfectly applicable to the bay of the external text in the appropriate colour, if the text is not transparent and understands that the reference is correct. Inside letter transparent♪ But it's the exact format that you need to fill without changing the inside. transparent In the original version.



  • There are, like, separate parameters for the colour of the text (fillcolor) and the colour of the background (bgcolor).

    From the response to en.SO: https://stackoverflow.com/q/10750352/2790048 ♪ I've given back the right lines.

    $width = '600';
    $height = '200';
    $im = new Imagick();
    $draw = new ImagickDraw();
    $draw->setFont('arial.ttf');
    $draw->setFontSize( 96 );
    

    $fillcolor = new ImagickPixel( "white" );

    $draw->setFillColor( $fillcolor );
    $draw->setGravity( Imagick::GRAVITY_CENTER );

    $bgcolor = new ImagickPixel( "black" );

    $text = 'Rubblewebs';
    $im->newImage($width, $height, $bgcolor );
    $im->annotateImage($draw, 0, 0, 0, $text);
    $im->setImageFormat("png");
    $im->writeImage( 'text.png' );


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2