I am trying to do a script that opens a remote gif-image file and writes it to a local file and then displays the image from the local file. This should be done without the GD library.
Key words here are: "gif-image" and "without the GD library".
I would appreciate it a lot if someone could help me with this. Thanks for the help in advance.
Here is my attempt to solve the above-mentioned problem:
(result: no image, no errors, no nothing)
<?php
$url = "http://.../image.gif";
$img_file = "img.gif";
// open the remote file.
$input = fopen($url, "rb");
// read the contents of the file.
$image_data = fread($input, 10000000);
fclose($input);
// write the contents to a img_file
$output = fopen($img_file, "wb");
fwrite($output, $image_data);
fclose($output);
// create the gif from the img_file
$img = $img_file;
$imageInfo = GetImagesize($img);
$file = fread(fopen($img_file, "r"), filesize($img_file));
header("Content-Type: image/gif");
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Expires: Sat, 1 Jan 2000 00:00:01 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
echo $file;
fclose($file);
?>