dokuwiki-plugin-dw2pdf icon indicating copy to clipboard operation
dokuwiki-plugin-dw2pdf copied to clipboard

Embedded PNG Image with alpha channel missing

Open ghost opened this issue 6 years ago • 7 comments

Exporting a namespace to PDF works fine, but PNG pictures with an alpha channel are missing. I'm using the following setup:

  • CentOS 7.4
  • DokuWiki Release 2017-02-19e "Frusterick Manners"
  • php 7.2 + GD (module loaded and tested with phpinfo(); )
  • latest dw2pdf plugin installed via DokuWiki plugin installer

JPEGs and PNG without alpha channel are rendered without any problems.

I tried to debug mPDF to see if it uses a wrong GD/php library and made a php site in the dw2pdf plugin root with following content:

 <?php
 require_once __DIR__ . '/vendor/autoload.php';
 $mpdf = new \Mpdf\Mpdf(['debug' => true]);
 $mpdf->showImageErrors = true;
 
 // Buffer the following html with PHP so we can store it to a variable later
 ob_start();
 
 echo '<div>PNG Image with alpha channel</div>';
 echo '<img src="image.png"/>';
 
 // Now collect the output buffer into a variable
 $html = ob_get_contents();
 ob_end_clean();
 
 // send the captured HTML from the output buffer to the mPDF class for processing
 $mpdf->WriteHTML($html);
 $mpdf->Output();
 ?>

That page outputs a PDF in my browser where the PNG with alpha channel is showing up as is should.

ghost avatar Mar 20 '18 15:03 ghost

Could you please provide sample images for me to reproduce this?

Klap-in avatar Mar 27 '18 20:03 Klap-in

Sure, i've made a PNG with alpha, one without and the resulting PDF generated from the wiki page: https://amd.co.at/shark/dw2pdf/

ghost avatar Mar 28 '18 06:03 ghost

Thanks! I have uploaded your pictures to my test wiki and included them as follows:

======test:alpha_pictures2pdf======
with alpha

{{:test:png_with_alpha.png?direct&400|}}

no alpha

{{:test:png_no_alpha.png?direct&400|}}

alpha
{{:test:png_with_alpha.png?direct|}}

Exporting that page results in a pdf with 3 times the picture, twice scaled, once at entire width of document. So far I could not reproduce your case...

I'm using here: DokuWiki version: Git 2018-03-28 (=latest development version, but I guess the latest stable release should not make a difference) PHP version 7.0.28-0ubuntu0.16.04.1 latest dw2pdf version of 2018-03-19 (published 2 days ago)

This last dw2pdf release has larger changes in the mpdf library, but so far I know no changes for pictures... but could you test if the last update of the dw2pdf still shows your issue?

Klap-in avatar Mar 29 '18 17:03 Klap-in

I made a wiki page with the same content as your test page. Updated dw2pdf to the newest version (had to uninstall and reinstall the plugin just like this issue.

I changed my php version and all dependent packages from 7.2 to 7.0 to be more close to your test scenario. I'm now using php 7.0.27.

But it still won't render the images correctly in the PDF. The thing that i found odd is, that the second resized picture in the wiki page {{:test:png_no_alpha.png?direct&400|}} won't render in the pdf, but if i change it to full size, it's being displayed correctly in the pdf export. Maybe the resizing of the picture re-adds the alpha channel to the picture...

ghost avatar Mar 30 '18 10:03 ghost

(#340 is solved. A clean up action was deleting too much. Sorry.)

Klap-in avatar Mar 30 '18 10:03 Klap-in

I've encountered similar problems while producing PDFs containting pictures inside.

ok: MyPaint (Linux) produced Jpg ok: MyPaint (Linux) produced Solid PNG

Not ok: MyPaint (Linux) produced Transparent PNG Not ok: Screenshot (Linux) paste by imgpaste plugin produced PNG


Ubuntu 17.10 PHP 7.1.15-0ubuntu0.17.10.1 DokuWiki Release 2017-02-19e "Frusterick Manners" Dw2Pdf plugin: 2018-03-30

hartmut27 avatar Apr 10 '18 22:04 hartmut27

Is this still reproduceable with the latest versions? (Please ensure GD module is also enabled.)

If still there: I have not yet a clue, so for further testing please check also with the 'dokuwiki' template. And provide test images and an example wiki article to help to reproduce the case.

Klap-in avatar Oct 12 '22 20:10 Klap-in

I consider this as solved in mean time.

Klap-in avatar Jul 30 '23 07:07 Klap-in