Jump to content

Archived

This topic is now archived and is closed to further replies.

corillo181

image

Recommended Posts

if it's already on your server - the getimagesize() function.

Share this post


Link to post
Share on other sites
under wher ein php info would i find that?

cuz i tthink is if i had gd? and my server do

i try this but it does not work.
[code]
<?php
function imageResize($width, $height, $target) {
if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = ($target / $height);
}
$width = round($width * $percentage);
$height = round($height * $percentage);
return "width=\"$width\" height=\"$height\"";
}

include 'includes/db.php';
$query=mysql_query("SELECT path FROM tra_cotm_photo")or die("error: ".mysql_error());
$path=mysql_fetch_array($query);
$test = getimagesize("../cotm/457565197.jpg");
?>
<img src="../cotm/457565197.jpg" <?php imageResize($test[0],$test[1], 110); ?> />
[/code]

Share this post


Link to post
Share on other sites
If you have the GD library installed, it's clearly visible in phpinfo (it has its own section of information).

If you have GD installed and your code "doesn't work", there something not right wih your code. What is (not) happening with that script that makes you think there's a problem?

Share this post


Link to post
Share on other sites
tha tpage does nto resize with the function made.. so i think the imagesiz eit's not doign the work

and yes the gd is on..

plus i try using
[code]<img src="image/123.jpg" atl="<?php getimagesize("image/123.jpg");?>">
[/code]
to see if it would show me the image size but it doesn't..

Share this post


Link to post
Share on other sites
getimagesize returns an array of values. Try this:
[code]$size = getimagesize("image/123.jpg");
echo "<img src='". image/123.jpg' ". $size[3]. ">";[/code]

Share this post


Link to post
Share on other sites
mm that code is wrong and i dont see how tha tis going to tell me in any way if the #size is working.

Share this post


Link to post
Share on other sites
Sorry, try this:
[code]$size = getimagesize("image/123.jpg");
echo "<img src='image/123.jpg' ". $size[3]. ">";[/code]
If GD is working and if image/123.jpg exists (it's your example, so I assume it would), then $size[3] will display the width and height of the image - exactly what it says in the php manual.

Share this post


Link to post
Share on other sites
this worked..i got the hang of it.. thanx
[code]

$filename = 'images/123.jpg';
$size = getimagesize("images/123.jpg");
$width=$size[0];
$height=$size[1];
if($width >100 || $height >100){
$n_w=$width / 2;
$n_h=$height / 2;
echo '<img src="images/123.jpg" width="'.$n_w.'" height="'.$n_h.'" />';
}
?>


[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.