0

Hi all,

I'm very new to php and I'm working on a project that require to create compcard that should be saved in a folder (uploade) which is working properly.
The problem is that now I have to preview that copcard (images) and ask user to save it or not. can anyone know. Plz help me.

my email is <email snipped>
Thank you

Edited by nav33n: Email address snipped. Please read forum rules. Do not post asking for an answer to be sent to you via email or PM.

2
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by Wraithmanilian
1
<?php 
// The file you are resizing 
$file = $_GET['filename'];

$sizeset = false;
list($width, $height) = getimagesize($file); 

//This will set our output size depending on input

if($_GET['pct']) {               // First type - percentage of original size
	$size = $_GET['pct']/100; 
	$modwidth = $width * $size; 
	$modheight = $height * $size; 
	$sizeset = true;
} 

if($_GET['maxw']) {               // Second type - Determine Max Width of thumbnails
	$wpct = $_GET['maxw'] / $width;
	$modwidth = $_GET['maxw'];
	$modheight = round($height*$wpct);
	$sizeset = true;
} 

if($_GET['maxh']) {               // Third type - Determine Max Height of thumbnails
	$hpct = $_GET['maxh'] / $height;
	$modheight = $_GET['maxh'];
	$modwidth = round($width*$hpct);
	$sizeset = true;
} 

if(!$sizeset) {	               // Fourth type - If nothing else specified, default to this percentage
	$size = .25;					// This is set for 25%
	$modwidth = $width * $size; 
	$modheight = $height * $size; 
} 

// This sets it to a .jpg, but you can change this to png or gif 
header('Content-type: image/jpeg'); 

// Resizing the Image 
$tn = imagecreatetruecolor($modwidth, $modheight); 
$image = imagecreatefromjpeg($file); 
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); 

// Outputting a .jpg, you can make this gif or png if you want 
//notice we set the quality (third value) to 100 
imagejpeg($tn, null, 100); 
?>

So, when you need the thumbnail, you can call it like these examples, depending on what you need:

<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg&pct=30">
<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg&maxw=150">
<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg&maxh=100">
<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg">

Edited by Wraithmanilian: Code Clarity

Votes + Comments
hey thanx Wraithmanilian
0

hey thanx Wraithmanilian

I'll try this. thanx a lot.

<?php 
// The file you are resizing 
$file = $_GET['filename'];

$sizeset = false;
list($width, $height) = getimagesize($file); 

//This will set our output size depending on input

if($_GET['pct']) {               // First type - percentage of original size
	$size = $_GET['pct']/100; 
	$modwidth = $width * $size; 
	$modheight = $height * $size; 
	$sizeset = true;
} 

if($_GET['maxw']) {               // Second type - Determine Max Width of thumbnails
	$wpct = $_GET['maxw'] / $width;
	$modwidth = $_GET['maxw'];
	$modheight = round($height*$wpct);
	$sizeset = true;
} 

if($_GET['maxh']) {               // Third type - Determine Max Height of thumbnails
	$hpct = $_GET['maxh'] / $height;
	$modheight = $_GET['maxh'];
	$modwidth = round($width*$hpct);
	$sizeset = true;
} 

if(!$sizeset) {	               // Fourth type - If nothing else specified, default to this percentage
	$size = .25;					// This is set for 25%
	$modwidth = $width * $size; 
	$modheight = $height * $size; 
} 

// This sets it to a .jpg, but you can change this to png or gif 
header('Content-type: image/jpeg'); 

// Resizing the Image 
$tn = imagecreatetruecolor($modwidth, $modheight); 
$image = imagecreatefromjpeg($file); 
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); 

// Outputting a .jpg, you can make this gif or png if you want 
//notice we set the quality (third value) to 100 
imagejpeg($tn, null, 100); 
?>

So, when you need the thumbnail, you can call it like these examples, depending on what you need:

<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg&pct=30">
<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg&maxw=150">
<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg&maxh=100">
<img src="http://www.mysite.com/theabovecode.php?filename=images/yourimage.jpg">
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.