garry Posted May 28, 2008 Share Posted May 28, 2008 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 More sharing options...
MadTechie Posted May 28, 2008 Share Posted May 28, 2008 it means file not found, does "/dev/albumart/watershed.jpg" exist ? Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551530 Share on other sites More sharing options...
mhodge_txs Posted May 28, 2008 Share Posted May 28, 2008 Hey this is my first post ! getimagesize(/dev/albumart/watershed.jpg) should be getimagesize(../dev/albumart/watershed.jpg) if the file exists that is Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551531 Share on other sites More sharing options...
garry Posted May 28, 2008 Author Share Posted May 28, 2008 The file exists, I used an <img src> test to make sure and the image showed up. It's supposed to be /dev/ as i'm using absolute path. Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551535 Share on other sites More sharing options...
MadTechie Posted May 28, 2008 Share Posted May 28, 2008 lets try something $filename = "/dev/albumart/watershed.jpg"; if (file_exists($filename)) { $avar = getimagesize($filename); }else{ die("No file"); } Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551539 Share on other sites More sharing options...
garry Posted May 28, 2008 Author Share Posted May 28, 2008 Hmm.. weird... Using this code displays the image: <img src="/dev/albumart/watershed.jpg" /> However, using your code, I get an error saying "No file" Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551542 Share on other sites More sharing options...
garry Posted May 28, 2008 Author Share Posted May 28, 2008 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( ["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! Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551548 Share on other sites More sharing options...
MadTechie Posted May 28, 2008 Share Posted May 28, 2008 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\" />"; } Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551554 Share on other sites More sharing options...
garry Posted May 28, 2008 Author Share Posted May 28, 2008 Thanks very much! That's all I need for now. I'll have a play around with this and see if I can get what I want working but I'm sure i'll run into more troubles later on the track. Thanks a bunch for your help, I really appreciate it Link to comment https://forums.phpfreaks.com/topic/107608-gd-image-manipulation/#findComment-551557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.