franknu Posted April 29, 2007 Share Posted April 29, 2007 Ok, i want to resize images in php the problem is that i want to resize the images when they display i wonder what is the best approach this is the code that i have to display the pictures <?php $image = preg_replace('#^.*/public_html#', '', $row['Picture3']); echo '<img src="' . $image . '" width="250" height="250">'; ?> basicly, i want the pictures to be resize proporsionaly help thank u Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/ Share on other sites More sharing options...
bobleny Posted April 29, 2007 Share Posted April 29, 2007 I generally don't like to do this, but take a look at this guys post. http://www.phpfreaks.com/forums/index.php/topic,138251.0.html I'm not saying his script works, but he does. It is interesting and it might give you some ideas for your own... Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/#findComment-241257 Share on other sites More sharing options...
papaface Posted April 29, 2007 Share Posted April 29, 2007 Its quite simple. Just use something like this <?php $path = "images/image.jpg"; $size = getimagesize($path); $height = $size[1] /5; $width = $size[0] / 5; ?> <img src="<?php echo $path; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>"> That will proportionally reduce the size by a 80% I think. Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/#findComment-241259 Share on other sites More sharing options...
franknu Posted April 29, 2007 Author Share Posted April 29, 2007 well that is to upload the file, i want to resize the images proporsionaly when i displayed it Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/#findComment-241260 Share on other sites More sharing options...
franknu Posted April 29, 2007 Author Share Posted April 29, 2007 what if i want to kinda asign a value like with 250 so what will be proportional well be the height to 250 Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/#findComment-241261 Share on other sites More sharing options...
papaface Posted April 29, 2007 Share Posted April 29, 2007 I think that is probably possible through simple calculations. Something like $height = "250"; $width = $size[0] / 100 * 250; Not sure if that would work, but you get the idea. Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/#findComment-241263 Share on other sites More sharing options...
dj-kenpo Posted April 30, 2007 Share Posted April 30, 2007 doing it that way is really heavy on the server cpu if you're getting even moderate hits. your site will slow down fast unless you have a dedicated server. Link to comment https://forums.phpfreaks.com/topic/49233-how-to-resize-images-in-php/#findComment-241410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.