dompdf icon indicating copy to clipboard operation
dompdf copied to clipboard

Image does not render properly

Open CodeWorldUser opened this issue 7 years ago • 28 comments

it gives image with black background and the text on image of white color

CodeWorldUser avatar Jan 09 '19 12:01 CodeWorldUser

I have questions:

  • What is the nature of the text?
  • Do you get any PHP errors?
  • How are you loading your HTML document into Dompdf?
  • How are you referencing your image from within Dompdf?
  • If the image is "remote" (i.e. starts with http://...), have you enabled remote resource access?

bsweeney avatar Jan 21 '19 15:01 bsweeney

Hey Brian,

  1. I am using normal html, which starts from <html> tag and end on </html>
  2. I didn't get any PHP error , it is successful but after rendering when I open pdf, then it has black and white image instead of colourful
  3. I tried both methods as via relative path of image and also with remote source, also I enabled remote resource access , But it will be helpful if you let me know How may I enable remote resource access within DOMPDF code

Thanks

On Mon, Jan 21, 2019 at 8:37 PM Brian Sweeney [email protected] wrote:

I have questions:

  • What is the nature of the text?
  • Do you get any PHP errors?
  • How are you loading your HTML document into Dompdf?
  • How are you referencing your image from within Dompdf?
  • If the image is "remote" (i.e. starts with http://...), have you enabled remote resource access?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dompdf/dompdf/issues/1877#issuecomment-456104952, or mute the thread https://github.com/notifications/unsubscribe-auth/AsXtaQukhj0zbD67XlKWO5NZ1u0yV8cHks5vFdfJgaJpZM4Z3WZG .

CodeWorldUser avatar Jan 23 '19 14:01 CodeWorldUser

So you see the image on the page but it's in black and white? Do you have a sample of the image and the rendered PDF?

bsweeney avatar Feb 17 '19 01:02 bsweeney

Access to remote resources is enabled via the options. Call the following after you instantiate Dompdf:

$dompdf->set_option('isRemoteEnabled', true);

bsweeney avatar Feb 17 '19 01:02 bsweeney

screenshot 2019-02-18 at 10 59 24 am Its paypal icon original as : screenshot 2019-02-18 at 11 01 10 am

CodeWorldUser avatar Feb 18 '19 05:02 CodeWorldUser

huh ... looks like either the mask is being rendered by itself or the transparency isn't being set correctly on the mask. Are you using GD, IMagick, or GMagick? And which version?

bsweeney avatar Feb 20 '19 21:02 bsweeney

That a screenshot of the image? Can you upload the actual image so I can test?

bsweeney avatar Feb 20 '19 21:02 bsweeney

I uploaded both the images original as well as its rendered output in comment https://github.com/dompdf/dompdf/issues/1877#issuecomment-464590877

Please have a look , The coloured image is original image and the b/w image is rendered output I get , instead this I want the rendered images same as original coloured image.

Also I am not using any of IMagick, GMagick or GD version. Thanks Codeworld

CodeWorldUser avatar Feb 21 '19 07:02 CodeWorldUser

The color image in your comment looks more like a screen shot than the actual image you're using (just based on the fuzziness and the transparency background). When I render it I get just what I see in the comment, not any kind of b/w image.

Also, that's a PNG, which requires some kind of image library (PHP typically provides GD by default). You can run phpinfo().

bsweeney avatar Feb 23 '19 18:02 bsweeney

Having the same issue with php 7.4.8. When I downgrade to php 7.3.20 it works normally/as expected.

Example:

robindirksen1 avatar Jul 13 '20 09:07 robindirksen1

@robindirksen1 are these the actual images you're trying to render? Screen shots don't really help because I can't use them to reproduce the issue and right now I don't have any ideas on what's happening.

bsweeney avatar Jul 13 '20 14:07 bsweeney

@bsweeney sorry, my fault.

  • used file: Octocat
  • Here is the screenshot of the recently generated file (php 7.4 mac): image
  • screenshot of the generated file (php 7.3 mac):

robindirksen1 avatar Jul 13 '20 14:07 robindirksen1

Thanks for the follow up. When I render with that image on a linux box it looks OK. Are you using IMagick/Gmagick with your PHP install or just relying on GD?

bsweeney avatar Jul 13 '20 14:07 bsweeney

@bsweeney yes, imagick (3.4.4) is installed.

robindirksen1 avatar Jul 24 '20 11:07 robindirksen1

Sorry, did you ever say what version of Dompdf you're using? And is that with ImageMagick 7? There was a transparency issue we had to address (595950cbcf67834beb82e5b4765e636f5e277d29) but that was fixed with 0.8.2.

bsweeney avatar Jul 25 '20 04:07 bsweeney

@bsweeney v0.8.5

robindirksen1 avatar Jul 27 '20 07:07 robindirksen1

I am also facing this issue specifically for png images

rathodbhavikkqc avatar Aug 11 '20 13:08 rathodbhavikkqc

dompdf version : 0.8.5 imagick version : 3.4.4 GD version : 2.1.0

Screenshot 2020-08-11 at 7 01 33 PM Screenshot 2020-08-11 at 7 01 36 PM Screenshot 2020-08-11 at 7 01 40 PM

rathodbhavikkqc avatar Aug 11 '20 13:08 rathodbhavikkqc

Well, at least we have confirmation for IMagick 3.4.4. Do you know the ImageMagick version?

bsweeney avatar Aug 19 '20 23:08 bsweeney

I still need to know which version of ImageMagick is being used behind the IMagick extension so I can troubleshoot further. I think as a fallback we'll make usage of Imagick/Gmagick configurable for a future release..

bsweeney avatar Nov 23 '20 00:11 bsweeney

hi - I have problem of png images coming out negative

hey in lib/CPdf.php down around line 5689

// Since ImageMagick7 negate invert transparency as default
if (\Imagick::getVersion()['versionNumber'] < 1800) {
    $alpha_channel->negateImage(true);
}

My version is 1802 - so negateImage is not being called

I'm using Alpine Linux with the channels set to latest-stable

  • PHP 7.4.15
  • php7-pecl-imagick-3.4.4-r7
  • imagemagick-libs-7.0.10.57-r0
  • imagemagick-7.0.10.57-r0

bravedave avatar Mar 04 '21 22:03 bravedave

hi @bsweeney - looking for advice as to how this issue will pan out (I think it should get a bug label)

not looking to be too in depth here but .. wait for a solution or be active in working around?

the comment there Since ImageMagick7 negate invert transparency as default, infers that there has been a change at that version, but my distribution (Alpine) does not not seem to reflect that .. I've only recently converted to this from fedora - I had contemplated CentOS

So what do you think. Is it something that will/should change in DomPDF ?, or do you think No it won't, could there be a bug in the Alpine package?, I could consider moving to another distro … (I actually moved to Alpine to get heif support in ImageMagick, but CentOS has it too, Alpine just a little more edge, CentOS more conservative)

The other option is to go with GMagick, which avoids this line (DomPDF seems to prefer this)

If it's going to be changed, I would change the line in my vendor folder and wait for the change to come through

bravedave avatar Mar 09 '21 00:03 bravedave

I think if we're going to support IMagick we should make sure the behavior is consistent across versions (as much as possible). So, yes, this will be addressed in a future release.

I didn't develop that logic, and I'm not familiar enough with the IMagick/ImageMagick code base to know what's going on here. I think the initial step I'd like to take would be to disable IMagick/Gmagick by default, and utilize an option to enable it. That way default installs will have consistent behavior across the board.

Then it's a matter of figuring out what's the appropriate method of determining feature support in the IMagick extension and ImageMagick version. Since querying the API doesn't seem to provide consistent results perhaps some type of feature testing is more appropriate. Worst case would be running a small (few pixel) sample file through IMagick and querying the result to see what the behavior is.

bsweeney avatar Mar 11 '21 15:03 bsweeney

Hello,

We are having similar issues and were wondering if this is related to this bug. The issues we are having is not with inline PNG images but with PNG background-images. The transparant part gets filled out with black. The foreground hasn't changed though. We are using a different PHP and Imagick / ImageMagick version, which could explain the different behavior.

PHP: 7.3.33 Imagick: 3.6.0 ImageMagick: 6.9.12-54

Is there any solution to this? We also have GD on the server (version 2.1.0). If this is not related to this bug and I should be making a new issue, please let me know.

9dninedegrees avatar Aug 04 '22 15:08 9dninedegrees

@9dninedegrees which version of Dompdf are you using? We addressed some version detection issues with more recent releases.

bsweeney avatar Aug 04 '22 17:08 bsweeney

Hi @bsweeney, we are using the latest version (2.0.0).

9dninedegrees avatar Aug 05 '22 08:08 9dninedegrees

I'll need to see if I can reproduce in my environment.

bsweeney avatar Aug 05 '22 17:08 bsweeney