Page 1 of 1

Problem with imagecreatetruecolor

Posted: Wed May 07, 2008 8:34 pm
by znewsham
Hello.

I am working on an app that will allow a series of boxes to be added to an image, with different rotations. As such, I have created my base img resource. Which worked fine.

The problem lies with trying to create an additional img resource for the box, so that it may be rotated, before adding to the main img. for some reason I always get the following error:
<b>Warning</b>: imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in <b>/mnt/Target01/334547/351713/www.delaced.com/web/content/cards/createNew2.php</b> on line <b>18</b><br />

The values getting passed to it are correct, as I have used them in other things (read only, they are never set). The values that are passed change, but an example of other ones that have been sent are "width:370.8904820" "height:200.83920" I figured this may be a problem with them not being integers, so I used both intval() and (int) to try to convert them (both of which seem to give width:3708 height:2008 very strange...Even so. No matter what values I pass, I cant make this work. If I use static values, it does work.

Any help will be appreciated.

Re: Problem with imagecreatetruecolor

Posted: Wed May 07, 2008 11:56 pm
by nowaydown1
From what you described, this does kinda sound like some sort of strange casting issue. I would just follow the standard debugging routine. Remove any type casting stuff that you've done as troubleshooting. Output those variables right before they're passed to imagecreatetruecolor(). Try to cast them against a few different types and see what you get (int), (float). If you still get weird numeric results, I would check bugs.php.net against whatever version of PHP you're running to see if it's some kind of known issue.

Not saying that's for sure your issue, but couldn't hurt to look :)

Re: Problem with imagecreatetruecolor

Posted: Thu May 08, 2008 4:57 am
by onion2k
Whatever you think you're passing to imagecreatetruecolor(), you're not. If you pass an int it'll work fine.

Re: Problem with imagecreatetruecolor

Posted: Thu May 08, 2008 6:32 am
by znewsham
hmm. Well I have tried static casting to an int, and tried using intval, and have outputted the number I am trying to use, and it comes out as a number. Is there anything else I can do to try to make this value an int? (It comes from $_POST if that helps). I have used this same variable for imagefilledrectangle() before, and it works fine.