[php-src] Issue #23459: imagegrabscreen() is extremely slow

From: Date: Tue, 25 Aug 2026 18:12:25 +0000
Subject: [php-src] Issue #23459: imagegrabscreen() is extremely slow
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-252666@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/23459 Author: divinity76 ### Description imagegrabscreen is extremely slow. The following code: ```php <?php $t = microtime(true); $h = imagegrabscreen(); $grab = microtime(true) - $t; echo 'Grab: ' . sprintf('%.9f', $grab) . " s\n"; ``` Resulted in this output: ``` PS C:\Users\hansh> php test.php Grab: 7.558355093 s ``` But I expected this output instead: ``` PS C:\Users\hansh> php test.php Grab: 0.58355093 s ``` Php needs about 7.5 seconds. For comparison, equivalent [Python-mss](https://github.com/BoboTiG/python-mss)+PIL code runs in about 0.26 seconds: ```py import time import mss from PIL import Image # 1. Grab Screen t = time.perf_counter() with mss.MSS() as sct: # <--- Updated to mss.MSS() # monitors[1] is the primary monitor (monitors[0] is all monitors combined) monitor = sct.monitors[1] sct_img = sct.grab(monitor) # Convert raw MSS pixels (BGRA) to a PIL Image (RGB) img = Image.frombytes("RGB", sct_img.size, sct_img.bgra, "raw", "BGRX") grab_time = time.perf_counter() - t print(f"Grab: {grab_time:.9f} s") ``` ``` PS C:\Users\hansh> python3 test.py Grab: 0.265929600 s ``` ### PHP Version ```plain Observed both windows 11 with PHP 8.5.1 (cli) (built: Dec 17 2025 10:55:54) (ZTS Visual C++ 2022 x64) Copyright (c) The PHP Group Zend Engine v4.5.1, Copyright (c) Zend Technologies with Zend OPcache v8.5.1, Copyright (c), by Zend Technologies and Windows Server 2025 with PHP 8.2.12 (cli) (built: Oct 24 2023 21:15:15) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.2.12, Copyright (c) Zend Technologies ``` ### Operating System Observed on both Windows Server 2025, and Windows 11, both x86-64

« previous php.bugs (#252666) next »