how can I force the browsers to refresh an image which is created with imagecreatefromjpeg
?
I know this SO question (PHP force refresh image) for if I have a real image, but I need to refresh the image I just created because regarding to the user actions (to highlight different positions on the image) the image is not refreshed probably and I have to manually force the browser to reaload it via STRG + F5
For example:
- Precondition: Browser has nothing in cache
- I login into account of userA and open the page in which the image is included and highlight some points on it -> image is created correctly
- I logout and login into userB and open the page in which the image is included and highlight some points on it -> I see the old image from userA
- I have to hit STRG + F5 to see the correct image of mine
- Conclusuion: Browser caches the image instead of recreating it
Mainpage (which is opend by user) contains this part:
<img src="http://<URL>/<dir>/draw.php">
The draw.php
file creates the image via:
ob_start();
// get $results (= points to highlight) from database - works fine
$img = draw_stars_into_small_starmap($results);
ob_end_clean();
header("Content-type: image/jpeg");
imagejpeg($img, null, 85);
imagedestroy($img);
And this functions highlights some points on the image
// $smallimg is the image from
// Results containing the points to highlight
function draw_stars_into_small_starmap($results) {
$smallimg = dirname(__FILE__) . "/nameofpicture.jpg";
// Which color for highlighting
$colormap = array(
'a' => array(240, 120, 120),
'o' => array(255, 128, 0),
'm' => array(0, 255, 0)
);
$width = 450;
$height = 100;
while ($row = od_mysql_fetch_array ($results)) {
$x = $row['xkoord'] / (610 / $width);
$z = $row['zkoord'] / (610 / $height);
$y = $row['ykoord'] / 5;
list($r, $g, $b) = $colormap[$row['type']];
$color = imagecolorallocate($smallimg, $r, $g, $b);
$x = floor($x);
$y = floor($y) + 50;
imagearc($smallimg, $x, $y, 9, 9, 0, 270, $color);
imagecolordeallocate($smallimg, $color);
}
return $smallimg;
}
Anyone has an idea?
P.S. I ONLY want to always force the browser to refresh this particular image (or the draw.php the image is placed in) but NOT all images on the website / server!