Skip to main content

Php Display image dynamically

<?php
        // We'll be outputting a JPEG
        header('Content-Type: image/jpeg');
         
        $img = @imagecreatefromjpeg("http://www.weewuu.com/sites/default/files/one_pixel_small_white_image.jpg");
         
        imagejpeg($img);
        imagedestroy($img);
       
        exit;

===============================================

$file = "sites/default/files/logo.png";

header('Content-type:' . mime_content_type($file));

readfile($file);

=================================================

 $imagestr = file_get_contents('http://www.weewuu.com/sites/default/files/one_pixel_small_white_image.jpg');
$image = imagecreatefromstring($imagestr);
header('Content-type: image/jpeg');
imagejpeg($image);

=======================================================