1

I am using 7.2.27 PHP version with Laravel 7.

Below code working on my local same configuration,

$captured = imagegrabscreen();
imagepng($captured, "~path/" . time() . ".png");
imagedestroy($captured);

But this code not working on live server it's throwing exception like, Fatal error: Uncaught Error: Call to undefined function imagegrabscreen() in ~file-path:11 Stack trace: #0 {main} thrown in ~file-path on line 11

I don't know what is the exact issue.

I also checked below answer but I don't know what is php_gd2.dll, https://stackoverflow.com/a/8715544/6656706

Edit: I also tried on AWS ec2 with xampp but not working ! I also tried by installing php_gd2.dll.

Any help will be appreciated !

Thanks.

Evgeny Ruban
  • 1,357
  • 1
  • 14
  • 20
Jaydeep Mor
  • 1,690
  • 3
  • 21
  • 39

1 Answers1

3

If the server is on Linux, it can't work because imagegrabscreen() is only supported on Windows:

Note:

This function is only available on Windows.

Also note that the screenshot is performed on the server. It will not capture the user screen.

Olivier
  • 13,283
  • 1
  • 8
  • 24
  • So what about if I create instance of `Windows Server 2019` ? – Jaydeep Mor Apr 19 '20 at 10:51
  • @JaydeepMor If you call the function on a Windows Server, it will capture the screen of that server (which is probably not what you want to do). – Olivier Apr 19 '20 at 11:12
  • exceptions exist ofc, i have a windows server where i call imagegrabscreen() regurarly.. because i have a MMORPG game client running there 24/7 playing a game when i don't have time :P – hanshenrik Apr 20 '20 at 00:01
  • Okay so any alternative way for achieve this ? Actually I need to capture user screen (Windows only). – Jaydeep Mor Apr 20 '20 at 09:28
  • @JaydeepMor A browser can't take a screenshot. Why do you need that anyway? – Olivier Apr 20 '20 at 10:20
  • Actually I have created one script for my organization for all employees. It is working locally as xampp saver installed locally. Now I got that is not possible from browser. Thanks a lot for all your kind help ! – Jaydeep Mor Apr 20 '20 at 10:24