[30715] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1960 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 3 14:09:44 2008

Date: Mon, 3 Nov 2008 11:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 3 Nov 2008     Volume: 11 Number: 1960

Today's topics:
    Re: /^From:.*?([\w.-]+@[\w.-]+)/ <xiaoxia2005a@yahoo.com>
    Re: /^From:.*?([\w.-]+@[\w.-]+)/ <xiaoxia2005a@yahoo.com>
    Re: /^From:.*?([\w.-]+@[\w.-]+)/ <tim@burlyhost.com>
    Re: A couple of questions regarding runtime generation  <bik.mido@tiscalinet.it>
    Re: A couple of questions regarding runtime generation  <bik.mido@tiscalinet.it>
    Re: A couple of questions regarding runtime generation  <bik.mido@tiscalinet.it>
    Re: How to get the memory address of a Perl variable in <joost@zeekat.nl>
        ImageMagick: Writing image with 4 colors and palette <josef.moellers@fujitsu-siemens.com>
    Re: ImageMagick: Writing image with 4 colors and palett <joost@zeekat.nl>
    Re: ImageMagick: Writing image with 4 colors and palett <josef.moellers@fujitsu-siemens.com>
    Re: ImageMagick: Writing image with 4 colors and palett <zentara@highstream.net>
    Re: ImageMagick: Writing image with 4 colors and palett <josef.moellers@fujitsu-siemens.com>
    Re: ImageMagick: Writing image with 4 colors and palett <josef.moellers@fujitsu-siemens.com>
    Re: ImageMagick: Writing image with 4 colors and palett <joost@zeekat.nl>
    Re: ImageMagick: Writing image with 4 colors and palett <josef.moellers@fujitsu-siemens.com>
    Re: ImageMagick: Writing image with 4 colors and palett <josef.moellers@fujitsu-siemens.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 3 Nov 2008 04:06:03 -0800 (PST)
From: April <xiaoxia2005a@yahoo.com>
Subject: Re: /^From:.*?([\w.-]+@[\w.-]+)/
Message-Id: <66b624c0-a89e-49df-85a0-c022b104e39a@z18g2000prn.googlegroups.com>

On Nov 3, 1:37=A0am, Tim Greer <t...@burlyhost.com> wrote:
>
> > I've started to love this place and you guys .. :-)
>
> BTW, if you know it'll only be white space (space, tabs, etc.) between
> the ^From:? and email@address, then \s+ would probably be a better
> idea... unless you suspect other non \w, ., and - characters will exist
> between it and don't want to try and predict them.
>

you mean '^From:\s+?', how about '^From:\s*?', to also cover the case
no white space or anything at all?


------------------------------

Date: Mon, 3 Nov 2008 04:28:40 -0800 (PST)
From: April <xiaoxia2005a@yahoo.com>
Subject: Re: /^From:.*?([\w.-]+@[\w.-]+)/
Message-Id: <71e0c156-d64d-4fbf-a6af-629dc786f59b@f37g2000pri.googlegroups.com>

On Nov 2, 11:30=A0pm, Scott Bryce <sbr...@scottbryce.com> wrote:

> He is not making accusations, and he is not upset. He is trying to help
> you communicate your questions in a way that makes it easier for the
> regulars here to answer them.

I assume that's the case now ..

>
> For example, in this line of code:
>
> elsif ($header && /^From:.*?([\w.-]+@[\w.-]+)/)
>
> We have no way of knowing what $header is used for, or what data it
> might contain.
>
> We have no way of knowing what $_ might contain.
>
> We don't know what you mean by "header section." Of a email? Or is your
> program divided up into "sections" that we are unaware of?
>
> Without knowing that we cannot know if $header contains a value that is
> different from what you think it holds, if $_ contains a different value
> than you think it does, or if the regex is wrong for what you are trying
> to accomplish.

I guess I could have done better .. I indicated this is an email
matching issue in the original post, and I remembered to use
meaningful variable name, and the && is a logical and, so then I
assumed people have the same thing in my mind and would understand I
was trying to take out any doubt related to $header, and can focus on
anything wrong with the part after &&.

>
> if you haven't already, take a look at the posting guidelines for this
> group. See if they help you ask your questions in a better way in the
> future. There is a lot of Perl talent here. (I normally don't respond to
> posts here, since there are others who give much better answers than I
> do.) If you are willing to work within their guidelines, there is a lot
> you can learn here.

I have taken note, thanks Scott.



------------------------------

Date: Mon, 03 Nov 2008 10:52:12 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: /^From:.*?([\w.-]+@[\w.-]+)/
Message-Id: <wLHPk.16035$AW.1372@newsfe01.iad>

April wrote:

> On Nov 3, 1:37 am, Tim Greer <t...@burlyhost.com> wrote:
>>
>> > I've started to love this place and you guys .. :-)
>>
>> BTW, if you know it'll only be white space (space, tabs, etc.)
>> between the ^From:? and email@address, then \s+ would probably be a
>> better idea... unless you suspect other non \w, ., and - characters
>> will exist between it and don't want to try and predict them.
>>
> 
> you mean '^From:\s+?', how about '^From:\s*?', to also cover the case
> no white space or anything at all?

Yes, if it might have white space or might have none at all, then \s*
for zero or more is what you want.  \s*? isn't necessary here, since
\s* is already zero or more, so making it an optional match doesn't
matter, since if it doesn't exist, it's already "zero".  Be sure to
make : optional on From though, since your examples don't have it each
time.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


------------------------------

Date: Mon, 03 Nov 2008 14:08:32 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: A couple of questions regarding runtime generation of REGEXP's
Message-Id: <9sttg4pjko3quu7ipiqqm1cfa7qcigc99m@4ax.com>

On Sun, 02 Nov 2008 22:41:28 -0800, Tim Greer <tim@burlyhost.com>
wrote:

>> # does not work, no way no how
>> $rx = qr{s/\Q$sometext\E/junk/g};
>> $data =~ $rx;
>
>Looks like you're unintentionally trying to run a regex within the
>regex, where the regex within is actually just trying to match a string
>(not a functional regex).

(S)he's just trying to "save" a substitution as first-order object,
and (s)he blindily tried some "random" syntax that's not going to work
of course.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Mon, 03 Nov 2008 14:14:52 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: A couple of questions regarding runtime generation of REGEXP's
Message-Id: <juttg4920bfqi2ra6ttkroduubcf6hn5jl@4ax.com>

On Mon, 03 Nov 2008 00:24:30 GMT, sln@netherlands.com wrote:

>I'm probably going to use some wrong terms here but I
>hope to give enough detail that I can get a definative
>resolution to this, once and for all.
>
>Basically I'm writing a sub that wants to take a regular
>expression as a parameter. It then blindly operates on data,
>matching, and posible substitution.
[cut]
># does not work, no way no how
>$rx = qr{s/\Q$sometext\E/junk/g};

Actually, this comes out oh so often! Others duly explained to you
what's going on. Bottom line is, you *can't* "save" a substitution as
a first order object of the language. The substitution part of a
substitution, though, is "simply" a string: well, either that or code
- if the /e modifier is supplied. In both cases you can *think* of it,
possibly at the expense of a tiny wrapper layer, as a sub. Thus a
solution to your problem, albeit not just as "slim" as you may have
hoped for, may be given in terms of a couple consisting of a regex and
a sub. Sounds reasonable?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Mon, 03 Nov 2008 14:22:25 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: A couple of questions regarding runtime generation of REGEXP's
Message-Id: <niutg4dbptnscihdi9ijtqvmp9apf8q2mu@4ax.com>

On Mon, 3 Nov 2008 13:37:21 +1100, Martien Verbruggen
<mgjv@heliotrope.com.au> wrote:

>> # does not work, no way no how
>> $rx = qr{s/\Q$sometext\E/junk/g};
>> $data =~ $rx;
>
>A bare regex is simply not going to work on the right hand side of a =~
>operator. It's the operator on the right hand side that does the
>matching, not the =~ operator itself. That only binds an expression
>instead of $_ to that matching operator.

This is simply not true:

  $ perl -E '$r=qr/\w+\s(\w+)\s\w+/;
  "foo bar baz" =~ $r and say $1'
  bar

In fact...

>More detail:
>
>From perlop:
>
>       Binary "=~" binds a scalar expression to a pattern match.  Certain
>       operations search or modify the string $_ by default.  This operator
>       makes that kind of operation work on some other string.  The right
>       argument is a search pattern, substitution, or transliteration.
                      ^^^^^^^^^^^^^^
                      ^^^^^^^^^^^^^^

It's simply *ad hoc* in Perl 5.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Mon, 03 Nov 2008 13:36:19 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: How to get the memory address of a Perl variable in XS
Message-Id: <8763n5q94s.fsf@zeekat.nl>

cyl <u8526505@gmail.com> writes:

> in Perl script,
>
> my @arr = (1,2,3);
> xs_test(\@arr);
>
> in XS code
>
> void xs_test()
> {
>       SV * sv = ST(0);
>
>       // get the memory address of this array reference and save it,
> but how?

What do you mean? That /is/ what you're doing.

> }
>
> How do I get the memory address of \@arr in xs_test?

void* address = (void*) sv;

> Will the content in that address change when exiting the xs_test
> function? Thanks.

That's always possible, but you probably should at least increment the
refcount on sv if you're planning on keeping it around.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Mon, 03 Nov 2008 10:20:30 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: ImageMagick: Writing image with 4 colors and palette
Message-Id: <gemfop$h9n$1@nntp.fujitsu-siemens.com>

I'd like to create a set of images that are subsequently used to build 
the menu part of a DVD. I may have to fine-tune colors and positions, 
I'd like to create them using a program where I can simply tweak some 
parameters rather than use an image manipulation program like gimp to 
draw the image(s), as I need 4 images: one that will later form the 
"background" and three that will be used to display the buttons. The 
latter have to have just 4 colors and have to have a palette.

I've tried all sorts of combinations of
$img->Set(type => 'Palette');
$img->Quantize(colors => 4);
but still, if I open the image in gimp, it still shows as RGB rather 
than indexed.

How do I make sure that an image I created has only 4 colors and a palette?

Thanks,

Josef
-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


------------------------------

Date: Mon, 03 Nov 2008 13:47:03 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <871vxtq8mw.fsf@zeekat.nl>

Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:

> I'd like to create a set of images that are subsequently used to build
> the menu part of a DVD. I may have to fine-tune colors and positions,
> I'd like to create them using a program where I can simply tweak some
> parameters rather than use an image manipulation program like gimp to
> draw the image(s), as I need 4 images: one that will later form the
> "background" and three that will be used to display the buttons. The
> latter have to have just 4 colors and have to have a palette.
>
> I've tried all sorts of combinations of
> $img->Set(type => 'Palette');
> $img->Quantize(colors => 4);
> but still, if I open the image in gimp, it still shows as RGB rather
> than indexed.
>
> How do I make sure that an image I created has only 4 colors and a palette?

I don't use the module (I prefer to use the command line versions of
image magick) but you probably want the -colors option (possibly with
the "-type palette" option) make /make sure you save to a file format
that supports palettes, like png/

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Mon, 03 Nov 2008 14:03:49 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <gemsrh$19u$1@nntp.fujitsu-siemens.com>

Joost Diepenmaat wrote:
> Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:
> 
>> I'd like to create a set of images that are subsequently used to build
>> the menu part of a DVD. I may have to fine-tune colors and positions,
>> I'd like to create them using a program where I can simply tweak some
>> parameters rather than use an image manipulation program like gimp to
>> draw the image(s), as I need 4 images: one that will later form the
>> "background" and three that will be used to display the buttons. The
>> latter have to have just 4 colors and have to have a palette.
>>
>> I've tried all sorts of combinations of
>> $img->Set(type => 'Palette');
>> $img->Quantize(colors => 4);
>> but still, if I open the image in gimp, it still shows as RGB rather
>> than indexed.
>>
>> How do I make sure that an image I created has only 4 colors and a palette?
> 
> I don't use the module (I prefer to use the command line versions of
> image magick) but you probably want the -colors option (possibly with
> the "-type palette" option) make /make sure you save to a file format
> that supports palettes, like png/

Bedankt, but I've tried that (see above). And ... yes, the output is 
going to be PNG, as spumux wants it that way. The main image will be 
converted to jpeg, and made into a short movie.

I can't use the command line version of ImageMagick as I need to have 
information like the bounding boxes of text items which I want to put 
into an XML file for spumux.

Groetjes,

Josef
-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


------------------------------

Date: Mon, 03 Nov 2008 08:23:04 -0500
From: zentara <zentara@highstream.net>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <thutg45ljhtbbr7ppuulh9d8tero1i6prq@4ax.com>

On Mon, 03 Nov 2008 10:20:30 +0100, Josef Moellers
<josef.moellers@fujitsu-siemens.com> wrote:

>I'd like to create a set of images that are subsequently used to build 
>the menu part of a DVD. I may have to fine-tune colors and positions, 
>I'd like to create them using a program where I can simply tweak some 
>parameters rather than use an image manipulation program like gimp to 
>draw the image(s), as I need 4 images: one that will later form the 
>"background" and three that will be used to display the buttons. The 
>latter have to have just 4 colors and have to have a palette.
>
>I've tried all sorts of combinations of
>$img->Set(type => 'Palette');
>$img->Quantize(colors => 4);
>but still, if I open the image in gimp, it still shows as RGB rather 
>than indexed.
>
>How do I make sure that an image I created has only 4 colors and a palette?
>
>Thanks,
>
>Josef

I believe you need to save the image as png to get a palette.
If you save as jpg, it won't work.

#!/usr/bin/perl
use warnings;
use strict;
use Image::Magick;

my $file = shift or die "Need a file $!\n";

my $img = Image::Magick->new;
$img->ReadImage($file);

$img->Quantize( colors => 4 );
$img->Set( type => 'Palette' );
$img->Write("$0.png");
__END__

zentara



------------------------------

Date: Mon, 03 Nov 2008 14:51:12 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <gemvkb$btk$1@nntp.fujitsu-siemens.com>

zentara wrote:
> On Mon, 03 Nov 2008 10:20:30 +0100, Josef Moellers
> <josef.moellers@fujitsu-siemens.com> wrote:
> 
>> I'd like to create a set of images that are subsequently used to build 
>> the menu part of a DVD. I may have to fine-tune colors and positions, 
>> I'd like to create them using a program where I can simply tweak some 
>> parameters rather than use an image manipulation program like gimp to 
>> draw the image(s), as I need 4 images: one that will later form the 
>> "background" and three that will be used to display the buttons. The 
>> latter have to have just 4 colors and have to have a palette.
>>
>> I've tried all sorts of combinations of
>> $img->Set(type => 'Palette');
>> $img->Quantize(colors => 4);
>> but still, if I open the image in gimp, it still shows as RGB rather 
>> than indexed.
>>
>> How do I make sure that an image I created has only 4 colors and a palette?
>>
>> Thanks,
>>
>> Josef
> 
> I believe you need to save the image as png to get a palette.
> If you save as jpg, it won't work.
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Image::Magick;
> 
> my $file = shift or die "Need a file $!\n";
> 
> my $img = Image::Magick->new;
> $img->ReadImage($file);
> 
> $img->Quantize( colors => 4 );
> $img->Set( type => 'Palette' );
> $img->Write("$0.png");
> __END__

BTDTNT :-(
See my codelines: I did try the colors and the type stuff to no avail.
I also tried your code on the output of my program, but "file" still says
PNG image data, 720 x 576, 16-bit/color RGBA, non-interlaced
and GIMP still has the indicator on Image -> Mode -> RGB.

I tried it the other way round: made it Indexed with 4 colors using 
GIMP, then used ImageMagick's "Get()" function to see what type and 
colors it had, but, not surprisinly, it said "PaletteMatte" (tried that, 
too) and colors=2.

BTW I'm using "ImageMagick 6.2.4 10/02/07 Q16".

Josef
-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


------------------------------

Date: Mon, 03 Nov 2008 14:52:43 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <gemvn7$btk$2@nntp.fujitsu-siemens.com>

zentara wrote:

> I believe you need to save the image as png to get a palette.
> If you save as jpg, it won't work.

Sorry, forgot: Yes, I do save them as PNGs, the conversion to jpeg is 
done later.

-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


------------------------------

Date: Mon, 03 Nov 2008 14:59:35 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <87wsfkq5a0.fsf@zeekat.nl>

Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:

> zentara wrote:

> See my codelines: I did try the colors and the type stuff to no avail.
> I also tried your code on the output of my program, but "file" still says
> PNG image data, 720 x 576, 16-bit/color RGBA, non-interlaced
> and GIMP still has the indicator on Image -> Mode -> RGB.
>
> I tried it the other way round: made it Indexed with 4 colors using
> GIMP, then used ImageMagick's "Get()" function to see what type and
> colors it had, but, not surprisinly, it said "PaletteMatte" (tried
> that, too) and colors=2.
>
> BTW I'm using "ImageMagick 6.2.4 10/02/07 Q16".
>
> Josef

I just tried that code:

my $file = shift or die "Need a file $!\n";

my $img = Image::Magick->new;
$img->ReadImage($file);

$img->Quantize( colors => 4 );
$img->Set( type => 'Palette' );
$img->Write("test.png");


and the output of "identify test.png" is:

test.png PNG 1600x1200 1600x1200+0+0 8-bit PseudoClass 4c 259kb 

note the 4c, indicating a 4 color palette. gimp opens it in indexed mode
too.

That's with Image::Magick 6.4.3 - you may want to try upgrading.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Mon, 03 Nov 2008 15:45:39 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <gen2qf$nkb$1@nntp.fujitsu-siemens.com>

Joost Diepenmaat wrote:
> Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:

>> BTW I'm using "ImageMagick 6.2.4 10/02/07 Q16".

> That's with Image::Magick 6.4.3 - you may want to try upgrading.

I was alrady afraid, that that would be the reason.

Thanks to both, you and Zentara,

Josef
-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


------------------------------

Date: Mon, 03 Nov 2008 16:12:55 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: ImageMagick: Writing image with 4 colors and palette
Message-Id: <gen4dj$t6i$1@nntp.fujitsu-siemens.com>

Joost Diepenmaat wrote:
> Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:
> 
>> zentara wrote:
> 
>> See my codelines: I did try the colors and the type stuff to no avail.
>> I also tried your code on the output of my program, but "file" still says
>> PNG image data, 720 x 576, 16-bit/color RGBA, non-interlaced
>> and GIMP still has the indicator on Image -> Mode -> RGB.
>>
>> I tried it the other way round: made it Indexed with 4 colors using
>> GIMP, then used ImageMagick's "Get()" function to see what type and
>> colors it had, but, not surprisinly, it said "PaletteMatte" (tried
>> that, too) and colors=2.
>>
>> BTW I'm using "ImageMagick 6.2.4 10/02/07 Q16".
>>
>> Josef
> 
> I just tried that code:
> 
> my $file = shift or die "Need a file $!\n";
> 
> my $img = Image::Magick->new;
> $img->ReadImage($file);
> 
> $img->Quantize( colors => 4 );
> $img->Set( type => 'Palette' );
> $img->Write("test.png");
> 
> 
> and the output of "identify test.png" is:
> 
> test.png PNG 1600x1200 1600x1200+0+0 8-bit PseudoClass 4c 259kb 
> 
> note the 4c, indicating a 4 color palette. gimp opens it in indexed mode
> too.
> 
> That's with Image::Magick 6.4.3 - you may want to try upgrading.

This is getting strange:

I upgraded to 6.4.5, thenI took your program, added the necessary 
decorations and
print $img->Get('version'), "\n";

josef@bounty:~/Perl$ ./Joost xB.png
ImageMagick 6.4.5 2008-11-03 Q16 http://www.imagemagick.org
josef@bounty:~/Perl$ identify test.png
test.png PNG 720x576+0+0 DirectClass 8-bit 5.2k 0.040u 0:01

It seems that it has to do with the fact that I have a transparent 
background ...

Josef
-- 
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1960
***************************************


home help back first fref pref prev next nref lref last post