Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-25-2009, 06:40 AM   PM User | #1
kamkam
Regular Coder

 
Join Date: Dec 2006
Posts: 306
Thanks: 24
Thanked 0 Times in 0 Posts
kamkam is an unknown quantity at this point
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); 



?>
kamkam is offline   Reply With Quote
Old 08-25-2009, 09:26 AM   PM User | #2
kamkam
Regular Coder

 
Join Date: Dec 2006
Posts: 306
Thanks: 24
Thanked 0 Times in 0 Posts
kamkam is an unknown quantity at this point
Thanks, i have solved out the problem already.

i just keep the

header('Content-type:image/jpeg');
kamkam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:10 AM.


Advertisement
Log in to turn off these ads.