Website Screenshot with PHP in Linux – Solved
Naser Sobhan
AI & Strategy Consultant

I have searched a lot for a proper solution to have websites screenshot with (with and height) and it was not hard until I used different other services on web which was free (limited) and sometimes using google services to solve this issue but I really don’t like to use free services and you know when it’s free there is a limit and it’s not okay and I can’t offered the pricing they have and it was not in my server and this is a problem here.
so I search more until I found a python file opensource project which helped me a lot and it’s actually way easier then using API from free services
https://github.com/maaaaz/webscreenshot
it can be easly instal into your ubuntu machin and will be runable with below command
xvfb-run webscreenshot -w 20 -o $pathtosave -v $url
$pathtosave: is the location that screenshot will be saved
$url: is the link of the webpage
it’s done. no it’s not what about php?
now just use exec function of php to do that job
$pathtosave = '/var/www/screenshots/';
$url = 'https://google.com';
exec("xvfb-run webscreenshot -w 20 -o $pathtosave -v $url");
then you can have your screenshot from google.com in /var/www/screenshots/

Written by
Naser Sobhan
A technology veteran with 18+ years building scalable systems for global enterprises. Now based in Rochester, MN, helping local businesses adopt AI safely and profitably.
How this is written: I'm a builder first, not a professional writer — my strength is the technical work, not turning it into prose. The ideas, opinions, and experience here are entirely mine, shaped by years actually doing this. I use AI to help organize my notes, tighten the language, and turn what's in my head into something worth reading.
Keep reading
All insights →
A HomeLab that have Enterprise Level AIOps
one Proxmox box, a Mac, two k3s clusters, no cloud rent Here’s how it actually works. Not a diagram I drew for a pitch deck — the real thing, warts and...

How to Design and Implement Software Architecture Patterns: 5 Best Practices
Designing and implementing software architecture patterns is a crucial aspect of software development. It is the foundation upon which the software is built,...

Unveiling the Top Traits of a Successful Software Engineer – What it takes to Excel in the Competitive World of Tech
In summary, a skilled software engineer should possess various technical abilities, a solid problem-solving aptitude, the ability to communicate effectively,...