Speed problem re rgb+alpha PNG
Henning Michael Møller Just <HenningMichael.MollerJust-B5obmGyaMydknbxzx/[email protected]> Mon, 23 Jun 2008 07:38:28 +0200
| Newsgroups | gmane.comp.lang.perl.modules.pdfapi2 |
|---|---|
| Message-ID | <[email protected]> |
Hi everyone
I'm having some trouble creating an image object with $img = $pdf->image_png(...)
The object is created and it works, but it takes a very long time. The image is 2482x3510 pixels and is RGBA ($cs == 6). The time is spent in the PDF::API2::Resource::XObject::Image::PNG::unprocess() function and then in the new() method in the lines
foreach my $n (0..($h*$w)-1) {
vec($dict->{' stream'},$n,$bpc)=vec($clearstream,($n*4)+3,$bpc);
vec($self->{' stream'},($n*3),$bpc)=vec($clearstream,($n*4),$bpc);
vec($self->{' stream'},($n*3)+1,$bpc)=vec($clearstream,($n*4)+1,$bpc);
vec($self->{' stream'},($n*3)+2,$bpc)=vec($clearstream,($n*4)+2,$bpc);
}
I'm supposing this is getting the alpha mask out from the image and then actually removing the transparent parts from the image? Or?
On our relatively fast servers, this is taking about 3-4 minutes. It turned out in this particular case we didn't need transparency so we just saved it without ($cs == 2) and it's almost instantaneous now.
But we will probably need transparency later, so I'd like to know if there's something I can do. I'd rather not publisice the image (we are doing this for a client), but I could send it privately for someone to examine closer.
Best regards
Henning Michael Møller Just