Site Builder
Editing:
screenshot-maker.php
writable 0666
<?php /* ------------------------------------------------------------------ WordPress Screenshot Resizer (800 × 600 PNG, white background) Requirements: PHP ≥ 7.4 + GD extension ------------------------------------------------------------------ */ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['shot'])) { if (!extension_loaded('gd')) { $error = 'GD extension is not enabled on this server.'; } elseif ($_FILES['shot']['error'] !== UPLOAD_ERR_OK) { $error = 'Upload failed – code '. $_FILES['shot']['error']; } else { $tmp = $_FILES['shot']['tmp_name']; $data = file_get_contents($tmp); $src = @imagecreatefromstring($data); if (!$src) { $error = 'Unsupported image format (use PNG or JPG).'; } else { $SW=800; $SH=600; // Screenshot frame $W = imagesx($src); $H = imagesy($src); $scale = min($SW/$W, $SH/$H, 1); // never upscale $newW = (int)($W*$scale); $newH = (int)($H*$scale); $dst = imagecreatetruecolor($SW, $SH); $white = imagecolorallocate($dst,255,255,255); imagefill($dst,0,0,$white); imagecopyresampled( $dst, $src, ($SW-$newW)/2, ($SH-$newH)/2, // center 0, 0, $newW, $newH, $W, $H ); imagepng($dst, 'screenshot-1.png'); imagedestroy($src); imagedestroy($dst); $generated = true; } } } ?> <!doctype html><html><head><meta charset="utf-8"><title>Screenshot → 800×600 PNG</title> <style>body{font-family:Arial,Helvetica,sans-serif;margin:40px}</style> </head><body> <h1>Screenshot Resizer (800 × 600)</h1> <form method="post" enctype="multipart/form-data"> <input type="file" name="shot" accept="image/png, image/jpeg" required> <button>Upload & Convert</button> </form> <?php if (!empty($error)): ?> <p style="color:red"><?=$error?></p> <?php elseif (!empty($generated)): ?> <h2>Result</h2> <img src="screenshot-1.png?<?=time()?>" width="400" alt="screenshot preview"><br> <a href="screenshot-1.png" download>Download screenshot-1.png</a> <?php endif; ?> <p style="margin-top:2em;font-size:.9em;color:#666"> • The script never leaves your server; the converted PNG is saved in the same folder.<br> • If the uploaded shot is smaller than 800×600 it will be centered on white – no blurry upscaling. </p> </body></html>
Save changes
Create folder
writable 0777
Create
Cancel