Jump to content

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\" />";
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.