homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Problem with imagesx

 7:05 am on Jan 2, 2009 (gmt 0)

Hi Guys,

I'm trying to create thumbnails for my website but I'm having a problem. When I use imagesx it keeps telling me "Warning: imagesx(): supplied argument is not a valid Image resource in ... on line 13". This is my code:

$basedir = "/home/blabla/public_html/blabla/";
$oSourceImage = $basedir."308.jpg";
$nWidth = imagesx($oSourceImage);
$nHeight = imagesy($oSourceImage);

What am I doing wrong here ? The picture is available in that specific directory.



 9:27 am on Jan 2, 2009 (gmt 0)

someone please ?


 9:40 am on Jan 2, 2009 (gmt 0)

I would start with the PHP online documentation for the imagesx [php.net] function which expects the argument being passed to be an image resource, as explained on that page:


An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().


 9:56 am on Jan 2, 2009 (gmt 0)

Hi Coopster,

I've already read the documentation yesterday evening, but now I really focused ;-) I guess I have to add the following code to make it work:
$basedir = "/home/blabla/public_html/blabla/";
$oSourceImage = $basedir."308.jpg";
$img = ImageCreateFromJpeg($oSourceImage);
$nWidth = imagesx($img);
$nHeight = imagesy($img);

I will check it out later on today. Thanks (again) for your help coopster!


 10:00 am on Jan 2, 2009 (gmt 0)

Now you're getting back on track :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved