amacks has asked for the wisdom of the Perl Monks concerning the following question:

Use case: bulk watermarking images.

I first generate a standard overlay image:
my $text_overlay = Image::Magick->new(); $text_overlay->Set(size=>'400x140'); $text_overlay->ReadImage('xc:white'); $text_overlay->Set(alpha=>'Activate'); $text_overlay->Transparent(color=>'white'); my $err=$text_overlay->Annotate(text=>"OverlayText", 'pointsize' =>14, 'font' => 'AvantGarde-DemiOblique', 'geometry' => "+20+20", 'fill' => 'black', 'antialias' => 'true', );
Then I composite that onto a base image
my $imageTool=Image::Magick->new(magick=>'JPEG'); my $image=$imageTool->read($image_filename); my $err=$imageTool->Composite( 'image' => $text_overlay, 'opacity' => '15%', 'compose' => 'Atop', 'rotate' => 5, 'tile' => 'true', );
The problem is that this outputs an image with the overlay as just a bunch of blocks http://www.wiglaf.org/aaronm/48572-1.jpg When I run via the convert CLI tool, it does as expected
$ convert -size 400x140 -font "AvantGarde-DemiOblique" -pointsize 14 - +fill black -antialias -alpha set -transparent white -annotate +20+20 +"OverlayText" xc:white white_text.png $ composite white_text.png 48572-1.jpg -tile -compose Atop -dissolve 1 +5% overlay_test.jpg
http://www.wiglaf.org/aaronm/overlay_test.jpg

This code worked (the perl code) until sometime in the last 8-12 months, but I don't know of anything that changed on the system. Any thoughts?

Replies are listed 'Best First'.
Re: PerlMagick renders text as blocks
by bliako (Abbot) on Sep 08, 2023 at 07:03 UTC

    could it be that it can not find the font (though it is clear it is installed)?

      Would be my first guess as well. Perhaps you’ve updated imagemagik (the cli bits and/or some of its dependencies) and those are now looking somewhere else that an older build of the XS bits in the Perl bindings isn’t?

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

        We're using the distro build of ImageMagick and PerlMagic. There was a newer build available from the vendor, but it didn't seem to fix anything
        ImageMagick-6.9.10.97-1.28.amzn1.x86_64 compat-ImageMagick-6.2.8.0-4.2.amzn1.x86_64 ImageMagick-devel-6.9.10.97-1.28.amzn1.x86_64 ImageMagick-perl-6.9.10.97-1.28.amzn1.x86_64 ImageMagick-c++-6.9.10.97-1.28.amzn1.x86_64 ImageMagick-c++-devel-6.9.10.97-1.28.amzn1.x86_64