How can a PHP file create a hyperlink that opens a jpg image in a local image viewing program instead of a browser?

One way to achieve this is by using PHP to generate an HTML link that points to the image file on the local server. By setting the "Content-Disposition" header to "attachment", the browser will prompt the user to download the file instead of displaying it in the browser. This will allow the user to choose their preferred local image viewing program to open the jpg file.

<?php
$imagePath = 'path/to/your/image.jpg';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($imagePath) . '"');
readfile($imagePath);
exit;
?>