Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    i want to output an image as jpg file not bitmap file

    Hi;

    I am trying to output an image to jpg file, but my code in the following output to bitmap file, Could anyone tell me why, please.


    PHP Code:
    <?php 
    header
    ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    header('Content-type:image/jpeg');  
    header('Content-type:image/gif'); 
    header('Content-type:image/pjpeg'); 
    header('Content-type:image/pipeg'); 
    header('Content-type:image/png'); 
    header('Content-type:image/x-png'); 

    function 
    resizeImage($originalImage,$toWidth,$toHeight$maintain=true){ 
        
    //check that image exists
        
    if (!is_file($originalImage) || !is_readable($originalImage)) return false;
        
    // Get the original geometry and calculate scales 
        
    list($width$height) = getimagesize($originalImage); 
        if (
    $maintain) list($newWidth$newHeight) = ( (($toWidth/$toHeight) > ($width/$height)) ?array (intval(($toWidth $width/$height)), intval($toHeight)) : array (intval($toWidth), intval(($toHeight $height/$width))));
        
        
    // Resize the original image 
        
    $imageResized imagecreatetruecolor($newWidth$newHeight); 
        
    $imageTmp     imagecreatefromjpeg ($originalImage); 
        
    imagecopyresampled($imageResized$imageTmp0000$newWidth$newHeight$width$height); 
        return 
    $imageResized;
    }

     
    $image=resizeImage("./upload/cat.jpg",200,200,"true"); //this one shows on the browser
    imagejpeg($imagenull20); 



    ?>

  • #2
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Thanks, i have solved out the problem already.

    i just keep the

    header('Content-type:image/jpeg');


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •