$image->Label(); not working at all, no errors.
Posted: 2014-06-09T08:20:12-07:00
Hello again.
This one is adjusting my opinion imagemagick. Noob alert, I am new to perl, so I say this to let you know I know that. Here is a test script I have used to proof the use of $image->Label(); :
Simply put: $image->Label(); is not doing anything. Label works from bash, but I cannot get it to work from Image::Magick (PerlMagick). No errors either.
So. What's up with that?
Here's the source for it, from magick-image.c:
Looks like another pointer to me: const char *label. And I suspect it is being set, but nothing is being done with it.
I figured if this is broken, then there would be lots of traffic about it. But perhaps not so many people use Image::Magick after all? I do not know. Nor do I know why coding according to documentation is failing. I'll try annotate if I have too, but the whole point of label is that it "labels", which I prefer to use on top of images for ecommerce display.
Labeling in Image::Magick just does not seem to do anything, at all.
David
This one is adjusting my opinion imagemagick. Noob alert, I am new to perl, so I say this to let you know I know that. Here is a test script I have used to proof the use of $image->Label(); :
Code: Select all
#!/usr/bin/env perl
# perl-jsiiw-Label-fail.pl: test script to learn/fix Image::Magick Label fail.
use strict;
use warnings;
use Image::Magick;
my ($i1, $i2); # for image files.
my $wtf; # for error codes.
# we assume the following test images. These are == to:
# Image1_label_test.png PNG 1432x1080 1432x1080+0+0 8-bit DirectClass 120KB 0.000u 0:00.000
$i1 = Image::Magick->new;
$wtf = $i1->Read("515A.png");
warn $wtf if $wtf;
$wtf = $i1->Label("%f"); # %f filename
warn $wtf if $wtf;
$wtf = $i1->Write("Image1_label_test.png");
warn $wtf if $wtf;
$i2 = Image::Magick->new;
$wtf = $i2->Read("516A.png");
warn $wtf if $wtf;
#$wtf = $i2->Label(text=>"%f"); # wrong, though you'd not get that from docs.
=pod
"The text parameter for methods, Annotate(), Comment(), Draw(), and Label() can include the image filename, type, width, height, or other image attribute by embedding these special format characters:" WTF?
=cut
$wtf = $i2->Label('Hello World!'); # Not even a string works. Tried double quotes too.
warn $wtf if $wtf;
$wtf = $i2->Write("Image2_label_test.png");
warn $wtf if $wtf;
print "\n\nDone. Now check files.\n";
So. What's up with that?
Here's the source for it, from magick-image.c:
Code: Select all
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a g i c k L a b e l I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MagickLabelImage() adds a label to your image.
%
% The format of the MagickLabelImage method is:
%
% MagickBooleanType MagickLabelImage(MagickWand *wand,const char *label)
%
% A description of each parameter follows:
%
% o wand: the magick wand.
%
% o label: the image label.
%
*/
WandExport MagickBooleanType MagickLabelImage(MagickWand *wand,
const char *label)
{
MagickBooleanType
status;
assert(wand != (MagickWand *) NULL);
assert(wand->signature == WandSignature);
if (wand->debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
if (wand->images == (Image *) NULL)
ThrowWandException(WandError,"ContainsNoImages",wand->name);
status=SetImageProperty(wand->images,"label",label);
if (status == MagickFalse)
InheritException(wand->exception,&wand->images->exception);
return(status);
}
I figured if this is broken, then there would be lots of traffic about it. But perhaps not so many people use Image::Magick after all? I do not know. Nor do I know why coding according to documentation is failing. I'll try annotate if I have too, but the whole point of label is that it "labels", which I prefer to use on top of images for ecommerce display.
Labeling in Image::Magick just does not seem to do anything, at all.
David