searls03 Posted September 7, 2011 Share Posted September 7, 2011 ok, I found this code somewhere and I am getting the errors Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/searls03/public_html/profile.php on line 35 Warning: imagefill() expects parameter 1 to be resource, boolean given in /home/searls03/public_html/profile.php on line 39. I can't seem to figure this out. the website is http://www.kevinmusselman.com/2009/02/access-webcam-with-flash/ <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */include_once "connect_to_mysql_1.php"; // Here we run a login check if (!isset($_SESSION['username'])) { $inactivityTime = time() - 120; // 2 minutes mysql_query("update `sessions` set `loggedin` = '0' where `activity` < '$inactivityTime' "); echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include // Place Session variable 'id' into local variable $username1 = $_SESSION['username']; $name1 = $_SESSION['name']; /** * Get the width and height of the destination image * from the POST variables and convert them into * integer values */ /** * Get the width and height of the destination image * from the POST variables and convert them into * integer values */ $w = (int)$_POST['width']; $h = (int)$_POST['height']; // create the image with desired width and height $img = imagecreatetruecolor($w, $h); // now fill the image with white since I'm not sending the 0xFFFFFF pixels // from flash? imagefill($img, 0, 0, 0xFFFFFF); $rows = 0; $cols = 0; // now process every POST variable which // contains a pixel color for($rows = 0; $rows < $h; $rows++){ // convert the string into an array of n elements $c_row = explode(",", $_POST['px' . $rows]); for($cols = 0; $cols < $w; $cols++){ // get the single pixel color value $value = $c_row[$cols]; // if value is not empty (empty values are the blank pixels) if($value != ""){ // get the hexadecimal string (must be 6 chars length) // so add the missing chars if needed $hex = $value; while(strlen($hex) < 6){ $hex = "0" . $hex; } // convert value from HEX to RGB $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); // allocate the new color // if a color was already allocated // we dont need to allocate another time // but this is only an example $test = imagecolorallocate($img, $r, $g, $b); // and paste that color into the image // at the correct position imagesetpixel($img, $cols, $rows, $test); } } } function genRandomString($length = 12) { $characters = '0123456789'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } $bar = genRandomString(); //This will create the file $fp = fopen("images/".$username1."/".$username1."-".$bar.".jpg", "w"); ob_start(); imagejpeg($img, "", 90); $img = ob_get_contents(); ob_end_clean(); fwrite($fp, $img); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/246664-webcam/ Share on other sites More sharing options...
gristoi Posted September 8, 2011 Share Posted September 8, 2011 are you posting the width and height of the image to that page? according to that error, your not Quote Link to comment https://forums.phpfreaks.com/topic/246664-webcam/#findComment-1266956 Share on other sites More sharing options...
searls03 Posted September 9, 2011 Author Share Posted September 9, 2011 No but I figured that that was supposed to be generated when the image is taken. How am I supposed to do it then? Quote Link to comment https://forums.phpfreaks.com/topic/246664-webcam/#findComment-1267229 Share on other sites More sharing options...
gristoi Posted September 9, 2011 Share Posted September 9, 2011 just had a quick look at the link you supplied. it is meant to post over the data. Make sure you have somethingn like firebug installed in your browser and follow the post request to make sure the variables are being passed.. also make sure the javascript is actually posting to the correct page Quote Link to comment https://forums.phpfreaks.com/topic/246664-webcam/#findComment-1267293 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.