Good day All
I have been search the forums and I truly hope that this is not a duplicate post because I cannot find the answer to this.
I have a system that is saving High Quality .png images into a database. I do not have control over this portion of the system.
I need to display the images on a webpage. I have this working but the images are 500k at the moment and I load up between 4 - 20 images at a time. Obviously this isn't just going to clean out my bandwidth but it's going to take a very long time to load.
I was wondering if it is possible to convert the PNG output to a smaller JPEG?
Here is the code I have managed to get working with the PNG's.
This is saved as getImageByPkey.php
<?php
$pkey = $_GET['pkey'];
$cam = $_GET['camera'];
include_once('database.php');
$sql = "select
pic
from
$cam
where
pkey = $pkey";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
$image = $row['pic'];
header("Content-type: image/png");
echo $image;
?>
I use this function to build the images based on an array of Primary Keys numbers.
function createImageList($pkey){ //Create image list from array of primary keys
$key = count($pkey);
$key = $key - 1;
for ($x=$key;$x>=1;$x--){
echo '<div>';
echo '<img src="getImageByPkey.php?camera='.$pkey[0].'&pkey='.$pkey[$x].'"><br>';
$timeDB = getPkeyTimeValue($pkey[0], $pkey[$x]);
$time = correctedTime($timeDB);
echo $time;
';
}
}
This code works to display the PNG's just fine. I just need to somehow output JPEGS rather than PNG's.
Please let me know if I have been unclear about anything and please let me know if this has been covered elsewhere.
I appreciate any advise on this.
Thank you