Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function withImage() return false #17

Open
libedux opened this issue Jan 24, 2019 · 6 comments
Open

function withImage() return false #17

libedux opened this issue Jan 24, 2019 · 6 comments

Comments

@libedux
Copy link

libedux commented Jan 24, 2019

I am using this package to apply watermark on pdf files bu watermark does not merged with pdf file, instead withImage() function return false.

  $watermark = 'images/watermark.png';

     if ($model->extension == 'pdf') {
        $pdf = new Watermark($fileName); // $fileName is string that contain path to pdf file
        $pdf->withImage($watermark);
     }

The problem is, it does not throw any error like file not exist or etc. it just returns false.

@ajaxray
Copy link
Owner

ajaxray commented Dec 13, 2019

Hello @libedux ,

Thanks for asking.
Can you please specify which one is your case?

  1. The file images/watermark.png exists at the correct path, but watermarking is not happening and withImage() returns false
  2. The image images/watermark.png does not exist at the correct path. So you are expecting an Exception/Error instead of returning false silently.

@rajansinghrawat
Copy link

rajansinghrawat commented Feb 12, 2020

Hello @ajaxray

I am getting same issue, I am using this sample code

use Ajaxray\PHPWatermark\Watermark;
include 'watermark/autoload.php';
$watermark = new Watermark(__DIR__ . '/pdf/order.pdf');
print_r($watermark);
$watermark->setPosition(Watermark::POSITION_TOP_RIGHT);
$watermark->setOffset(50, 50);
$watermark->setOpacity(.2);
$watermark->setTiled();
var_dump($watermark->withImage(__DIR__ . '/img/logo.png', __DIR__ . '/pdf/result_img.pdf'));

@ajaxray
Copy link
Owner

ajaxray commented May 8, 2020

Hello @rajansinghrawat and @libedux

I have added a section for debugging steps in README.
Can you please try and let me know the outcome?

@convers39
Copy link

convers39 commented Nov 4, 2021

I got the same issue with some extra text:

        if (File::exists($file_path)) {

            $watermark = new Watermark($file_path);

            $watermark->withImage(public_path('image.jpg'))
                ->setPosition(Watermark::POSITION_BOTTOM_RIGHT)
                ->write($file_path);
        }

It gives me:

Invalid Parameter - -alpha
Invalid Parameter - 100
PHP Error:  Call to a member function setPosition() on bool

Both $file_path and public_path('image.jpg') are absolute pathes, which can be check with File::exists($path) method.

@ajaxray
Copy link
Owner

ajaxray commented Nov 4, 2021

@convers39 Can you please tell me your version of ImageMagick installation?

@xihuantudi
Copy link

@convers39 I guess that you are using the v0.1.2,and running example in github.The style in v0.1.2 is like
$watermark->setPosition(watermark::POSITION_BOTTOM_RIGHT);
$watermark->withImage($image.jpg, $file_path);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants