Jump to content

GD image manipulation


garry

Recommended Posts

So I'm trying to manipulate some images for my website. I've checked and apparently the GD image library is installed.

 

But when I use the getimagesize(); function, I get the following error:

 

Warning: getimagesize(/dev/albumart/watershed.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/dev/test.php on line 23

 

Why does this happen? :/

Link to comment
https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/
Share on other sites

Okay turns out it was my fault, I was using the html path for the image instead of the full server path for the php. When I use the full server path the error goes away and the area is just blank. I used var_dump on the variable and got the following array:

 

array(7) { [0]=>  int(300) [1]=>  int(300) [2]=>  int(2) [3]=>  string(24) "width="300" height="300"" ["bits"]=>  int(8) ["channels"]=>  int(3) ["mime"]=>  string(10) "image/jpeg" }

 

Now how can I use this information to resize the image and such? Sorry for newb question!

Okay well the imagesize is working

you can create a php file to resize the image OR use HTML

try something like this

 

$filename = "/dev/albumart/watershed.jpg";
if (file_exists($filename))
{
list($width, $height, $type, $attr) = getimagesize($filename);
//find the larger size
if($height > $width){
$size = "height=\"50px\"";
}else{
$size = "width=\"50px\"";
}
echo "<img src=\"img/flag.jpg\" $size  alt=\"flag\" />";
}else{
echo "<img src=\"img/noflag.jpg\" height=\"50px\" alt=\"missing flag\" />";
}

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.