From c7f0c2e46ea07d9e8ca2e9ee71065b9171d9bf8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Filipe?= Date: Thu, 28 Jul 2016 16:21:08 +0100 Subject: [PATCH] Default background color in case of png is transparent --- README.md | 1 + demo/index.html | 3 +-- src/Capture.php | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 90a8a075..3e79cf16 100755 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ And the resulted image format // allowed formats are 'jpg' and 'png', default is 'jpg'. $screenCapture->setFormat('png'); ``` +* If the format is ```jpg``` and the background color is not set, the default value will be ```#FFFFFF```, if ```png``` the default background color will be transparent. And most importantly, save the result ``` php diff --git a/demo/index.html b/demo/index.html index b39ab709..306e8ca4 100644 --- a/demo/index.html +++ b/demo/index.html @@ -97,7 +97,6 @@

Give it a test drive...

-
Give it a test drive...
- +
diff --git a/src/Capture.php b/src/Capture.php index 8f1fe757..e75b2ca1 100644 --- a/src/Capture.php +++ b/src/Capture.php @@ -54,7 +54,7 @@ class Capture * * @var string */ - protected $backgroundColor = '#FFFFFF'; + protected $backgroundColor = ''; /** * Image format @@ -135,6 +135,10 @@ public function save($imageLocation, $deleteFileIfExists = true) if ($this->backgroundColor) { $data['backgroundColor'] = $this->backgroundColor; + } elseif ($this->getFormat() == 'jpg') { + // If there is no background color set, and it's a jpeg + // we need to set a bg color, otherwise the background will be black + $data['backgroundColor'] = '#FFFFFF'; } if ($this->userAgentString) {