Jump to content

Image resizing


MetroidMaster1914

Recommended Posts

So I'm trying to take an image, not knowing what the image sizes may be, and shrinking it if it's bigger than 100px to a max width/height of 100px. Here is my problem: The page always takes a long time to load when it comes to animated images. Sometimes it just gives up and stops loading the page.

 

The page: http://www.metroidheadquarters.com/staff/

 

The code used to resize:

<img src='<?php echo $avatar; ?>' <?php
$imagesize = getimagesize($avatar);
$width = $imagesize[0];
$height = $imagesize[1];
if ($width > $height){
if ($width > 100) {
echo "width='100'";
}
} else {
if ($height > 100) {
echo "height='100'";
}
}
?>
alt='<?php echo $name; ?>'>

 

If you need more info, let me know. I'd appreciate any and all help in this matter.

Link to comment
https://forums.phpfreaks.com/topic/128894-image-resizing/
Share on other sites

thanks for the link. It says I need a GD library though. How can I find out if I have it on my server, and if it's not there, how can I put it there?

 

if im not mistaken its usually installed by default

 

just run the following phpscript on your server:

 

<?php phpinfo(); ?>

 

and search for "gd" :)

 

you should find something like this:

 

GD Support: enabled

Link to comment
https://forums.phpfreaks.com/topic/128894-image-resizing/#findComment-668429
Share on other sites

Archived

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

×
×
  • Create New...

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.