Problem with imagecreatetruecolor

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
znewsham
Forum Newbie
Posts: 3
Joined: Wed May 07, 2008 8:29 pm

Problem with imagecreatetruecolor

Post 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.
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: Problem with imagecreatetruecolor

Post 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 :)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Problem with imagecreatetruecolor

Post by onion2k »

Whatever you think you're passing to imagecreatetruecolor(), you're not. If you pass an int it'll work fine.
znewsham
Forum Newbie
Posts: 3
Joined: Wed May 07, 2008 8:29 pm

Re: Problem with imagecreatetruecolor

Post 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.
Post Reply