Jump to content

spectacularstuff

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Everything posted by spectacularstuff

  1. GD Image resizing seems to be pretty straight forward however I have managed to screw this up and need some help. I believe it is the If and Else statements that are screwing it up. Here is my scenario. 1. I am detecting user screen width in JavaScript and sending the information via a variable back to php when calling the images. The Javascript I wrote works no problem. 2. The detecting of the variables works no problem. 3. The initial displaying images to the screen without the If/Else statements works no problem. There must be something screwed up in my PHP If/Else statements but I am not sure what. Spectacular Computer Repair OR http://67.199.62.141/test4.php Below, you will find 2 IF/Else statements. The one for JPG I was working on in an attempt to get this working. The others do not have the resize part in it. I merely wanted the images to show up first with the statements before I resized them. PHP Code <?php $percent = 0.5; // Change this to reduce images by percentange based upon an 800 pixel width or below. $imgp = $_GET["imgpath"]; // The image pathway returned from JavaScript. (ie. images/) $width = $_GET["width"]; // The users screen width returned from JavaScript? (ie 800) $imgn = $_GET["imgname"]; // The image name returned from JavaScript. (ie scrfix-logo.png) $ext = substr($imgn, strrpos($imgn, '.') + 1); // Find the extension from the image name (ie jpg) $image = $imgp . $imgn; // Combine the pathway and the image name together (ie images/scrfix-logo.png) header("Content-Type: image/" . $ext); // What type of image are we working with? //Test to see what type of file is loaded. Even if an incorrect extension is loaded, load the image. function open_image($file) { # JPEG: $img = @imagecreatefromjpeg($file); //Test to see if we can find the image if ($img !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($file); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $resize = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($file); // Resize imagecopyresized($resize, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); break; } else { // Do Nothing } return $resize; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { if($width=<800) { // Get new sizes list($width, $height) = getimagesize($im); $newwidth = $width * $percent; $newheight = $height * $percent; break; } else { // Do Nothing } return $im; } return false; } // Test what extension we are working with and display the image. switch($ext) { case "png": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagepng($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "jpg": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagejpeg($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "jpeg": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagejpeg($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "gif": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegif($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "gd": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegd($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "gd2": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegd2($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "wbmp": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagewbmp($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "xbm": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagepng($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "xpm": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagexpm($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; default: echo "Unable to find any images."; } ?> Thanks for any insight. Wayne
  2. Use this php code instead. I forgot the cleanup in the one above. The above HTML and JavaScript is still okay however. Save this file as shrink.php and keep it in the same directory as the above file. PHP Code <?php $imgp = $_GET["imgpath"]; // The image pathway returned from JavaScript. (ie. images/) $width = $_GET["width"]; // The users screen width returned from JavaScript? (ie 800) $imgn = $_GET["imgname"]; // The image name returned from JavaScript. (ie scrfix-logo.png) $ext = substr($imgn, strrpos($imgn, '.') + 1); // Find the extension from the image name (ie jpg) $image = $imgp . $imgn; // Combine the pathway and the image name together (ie images/scrfix-logo.png) header("Content-Type: image/" . $ext); // What type of image are we working with? //Test to see what type of file is loaded. Even if an incorrect extension is loaded, load the image. function open_image($file) { # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } return false; } // Test what extension we are working with and display the image. switch($ext) { case "png": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagepng($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "jpg": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagejpeg($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "jpeg": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagejpeg($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "gif": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegif($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "gd": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegd($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "gd2": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegd2($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "wbmp": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagewbmp($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "xbm": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagepng($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; case "xpm": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagexpm($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagedestroy($image); break; default: echo "Unable to find any images."; } ?>
  3. This was resolved in a different forum (http://phpbuilder.com/board/showthread.php?&t=10356974&is_resolved=1) Here is the code to output multiple images between JavaScript and GD PHP. This script doesn't nothing more at this time than detect the images and screen width of the user and output the images. I do not have anything in here yet for resizing the images according to users width. I will work on that next. URL Spectacular Computer Repair HTML and JavaScript Code The JavaScript code must go on your webpage, preferably in between the <head></head> tags. I tried it as a .js file and it wasn't working. I don't know why. The code has been cleaned up a little to make it a little more user-friendly to read. <html> <head> <title></title> <head> <script language="javascript" type="text/javascript"> function resize() { // Variables to be sent to PHP. The PHP variables to be sent are in "" (ie width=, imgpath=) var width = "width=" + screen.width; // Set variable width to users screen width var path = "imgpath=images/&"; // Set the path to the image var logo = "imgname=scrfix-logo.png&"; //Name of my image var shopping = "imgname=shopping-cart.jpg&"; //Name of my image var forums = "imgname=forums.jpg&"; //Name of my image var signin = "imgname=sign-in.jpg&"; //Name of my image var contact = "imgname=contactus.jpg&"; //Name of my image var printer = "imgname=printer.jpg&"; //Name of my image // End of Variables to be sent to PHP. The below variables are only for this script. var script = "shrink.php?"; // The name of the php script var scrpth = script + path; //Combine both the script and the path to make it less to work with below. document.write('<a href="/"><img class="headerimages" src="' + scrpth + logo + width + '" alt="Spectacular Computer Repair" title="Spectacular Computer Repair" /></a>'); document.write('<a href="/catalog/"><img class="headerimages" src="' + scrpth + shopping + width + '" alt="Computer Repair Shopping" title="Computer Repair Shopping" /></a>'); document.write('<a href="/computer-repair-forums/"><img class="headerimages" src="' + scrpth + forums + width + '" alt="Computer Repair Forums" title="Computer Repair Forums" /></a>'); document.write('<a href="/coordinator.php"><img class="headerimages" src="' + scrpth + signin + width + '" alt="User Sign In" title="User Sign In" /></a>'); document.write('<a href="/contact.php"><img class="headerimages" src="' + scrpth + contact + width + '" alt="Contact Spectacular Computer Repair" title="Contact Spectacular Computer Repair" /></a>'); document.write('<a href="#" onclick="window.print();return false;"><img class="headerimages" src="' + scrpth + printer + width + '" alt="Print This Page" title="Print This Page" /></a>'); return 0; } </script> </head> <body> <script language="javascript" type="text/javascript"> resize(); </script> </body> </html> Save this file as shrink.php and keep it in the same directory as the above file. PHP Code <?php $imgp = $_GET["imgpath"]; // The image pathway returned from JavaScript. (ie. images/) $width = $_GET["width"]; // The users screen width returned from JavaScript? (ie 800) $imgn = $_GET["imgname"]; // The image name returned from JavaScript. (ie scrfix-logo.png) $ext = substr($imgn, strrpos($imgn, '.') + 1); // Find the extension from the image name (ie jpg) $image = $imgp . $imgn; // Combine the pathway and the image name together (ie images/scrfix-logo.png) header("Content-Type: image/" . $ext); // What type of image are we working with? //Test to see what type of file is loaded. Even if an incorrect extension is loaded, load the image. function open_image($file) { # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } return false; } // Test what extension we are working with and display the image. switch($ext) { case "png": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagepng($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "jpg": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagejpeg($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "jpeg": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagejpeg($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "gif": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegif($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "gd": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegd($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "gd2": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagegd2($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "wbmp": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagewbmp($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "xbm": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagepng($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "xpm": $image = open_image($image); // Image name from JavaScript passed to the open_image function. imagexpm($image); // Display the image to the browser //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; default: echo "Unable to find any images."; } ?>
  4. When I call it like that, the images don't show up.
  5. I am utilizing JavaScript to send variables to PHP and utilizing GD within PHP to display the images so I can have all of the DS functionality available to me. I have this working to an extent however cannot get the images to show up. I can see the placemats for the images and the borders however no images. Can someone help with this and point me in the right direction? I have 2 questions. 1. I want to use my JavaScript in a .js file instead of directly on the page a but it doesn't show any images when I utilize it that way. 2. I need the images to actually show up after they are run through the GD programming. My ultimate goal is to detect the users screen width in JavaScript, send that back to PHP and reduce the images based upon whether or not the user is looking at the webpage at an 800 screen width or lower. URL Spectacular Computer Repair OR http://67.199.62.141/test4.php My code is below: HTML & JavaScript Code <html> <head> <title></title> <head> <script language="javascript" type="text/javascript"> function resize() { var width = "width=" + screen.width; var path = "imgpath=images/&"; var script = "shrink.php?"; var logo = "imgname=scrfix-logo.png&"; var shopping = "imgname=shopping-cart.jpg&"; var forums = "imgname=forums.jpg&"; var signin = "imgname=sign-in.jpg&"; var contact = "imgname=contactus.jpg&"; var printer = "imgname=printer.jpg&"; document.write('<a href="/"><img class="headerimages" src="' + script + path + logo + width + '" alt="Spectacular Computer Repair" title="Spectacular Computer Repair" /></a><a href="/catalog/"><img class="headerimages" src="' + script + path + shopping + width + '" alt="Computer Repair Shopping" title="Computer Repair Shopping" /></a><a href="/computer-repair-forums/"><img class="headerimages" src="' + script + path + forums + width + '" alt="Computer Repair Forums" title="Computer Repair Forums" /></a><a href="/coordinator.php"><img class="headerimages" src="' + script + path + signin + width + '" alt="User Sign In" title="User Sign In" /></a><a href="/contact.php"><img class="headerimages" src="' + script + path + contact + width + '" alt="Contact Spectacular Computer Repair" title="Contact Spectacular Computer Repair" /></a><a href="#" onclick="window.print();return false;"><img class="headerimages" src="' + script + path + printer + width + '" alt="Print This Page" title="Print This Page" /></a>'); return 0; } </script> </head> <body onLoad="resize()"> </body> </html> PHP Code <?php $imgp = $_GET["imgpath"]; // The image pathway returned from JavaScript. (ie. images/) $width = $_GET["width"]; // The users screen width returned from JavaScript? (ie 800) $imgn = $_GET["imgname"]; // The image name returned from JavaScript. (ie scrfix-logo.png) $ext = substr($imgn, strrpos($fn, '.') + 1); // Find the extension from the image name (ie jpg) header("Content-type: image/{$ext}"); // What type of image are we working with? function open_image($file) { # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } return false; } switch($ext) { case "png": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagepng($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "jpg", "jpeg": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagejpeg($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "gif": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagegif($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "gd": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagegd($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "gd2": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagegd2($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "wbmp": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagewbmp($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "xbm": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagepng($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; case "xpm": $image = open_image($imgp . $imgn); // Image name from JavaScript passed to the open_image function. imagexpm($image); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } break; default: echo "Unable to find any images."; } ?> Thanks for any help, Wayne
  6. Here is what I believe you are looking for written in PHP. http://www.phpclasses.org/browse/package/1964.html If that doesn't work, you can search through google with this search. http://www.google.com/search?q=DHTML+Progress+Bar+Code&rls=com.microsoft:*:IE-Address&ie=UTF-8&oe=UTF-8&sourceid=ie7&rlz=1I7DKUS
  7. I guess we are at a loss for what you need the progress bar for. If we new what the application was, we can point you in the correct direction. Progress bars are done phenomenally in both DHTML and Flash however depending on what you are using it for those may not work for you. You can try this: http://slayeroffice.com/code/gradientProgressBar/ Wayne
  8. Notes I have the issue resolved with one image in GD and I could easily copy that code 5 or 6 times to get multiple images to output however I would like to do this a little easier but and running into a road block. This problem I am sure is due to my lack of experience in programming with GD. Issue I am attempting to use an array and a for statement to output multiple images in GD as is done with anything else I have worked with. When I attempt to run an array of images via a FOR loop I get no image and no multiple images. URL Broken Code URL: Spectacular Computer Repair OR http://67.199.62.141/test3.php whichever you prefer. Correct Code to OUTPUT 1 Image URL: Computer Repair Sarasota, Bradenton, Venice OR http://67.199.62.141/test2.php whichever you prefer. Broken Code <?php function open_image($file) { # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } return false; } header ('Content-Type: image/png'); // What type of image are we working with? I also need to learn how to output multiple headers if I am using different images. //$image = open_image('SCRFix-logo.png'); // Where is the image located? //Image array and their correct locations. $image = array("/images/scrfix-logo.png", "/images/shopping-cart.jpg", "/images/forums.jpg", "/images/sign-in.jpg", "/images/contactus.jpg", "/images/printer.jpg"); //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } for ($i = 1; $i < 6; $i++) { $image = open_image($image); imagepng($image); // Outputs to browser directly only once through GD Code however this doesn't return an image. } //imagejpeg($image); //Here for testing purposes because I have multiple different types of images, both png and jpg for quick loading. ?> Correct Code to OUTPUT 1 Image <?php function open_image($file) { # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } return false; } header ('Content-Type: image/png'); // What type of image are we working with? $image = open_image('SCRFix-logo.png'); // Where is the image located? what is the image named? Do not use a / in the beginning of the location ie. /images/SCRFix-Logo.png is a no no. Use images/SCRFix-logo.png //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } imagepng($image); ?> Any help would be appreciative. You can find all of the images I am working with here Image Locations http://67.199.62.141/images/scrfix-logo.png http://67.199.62.141/images/shopping-cart.jpg http://67.199.62.141/images/forums.jpg http://67.199.62.141/images/sign-in.jpg http://67.199.62.141/images/contactus.jpg http://67.199.62.141/images/printer.jpg Thanks, Wayne
  9. That was it! Thanks. No, I didn't realize that I couldn't output that within that code. I had kept it out of the GD code. I didn't realize that I couldn't have ANY other output Thank you for your help. That is one issue down and the rest to go. Now that I have that set up, I am going to work on the for statement for outputting multiple pictures from an array of images. If I run into issues with that I will post again. Thanks again. Wayne
  10. Okay, Side Note Strange on the infections that showed up on the computer I was using. I uninstalled FileZilla and they went away, ran two different on demand AV scanners and they returned no infections. Current Issue I have moved this over to another page and tried some different very simple code to attempt to get 1 picture to show up. I am not sure what is happening. I still cannot get a picture to show up. I have the correct header information. I have the correct pathway. New URL: http://67.199.62.141/test3.php If you view source, will see I have attempted to output to browser and failed. 1. Reads as if I do not have proper header information but I do. Here is the new code: <?php header ('Content-Type: image/png'); // What type of image are we working with? $image = open_image('SCRFix-logo.png'); // Where is the image located? //Check to see if we can find the image if ($image === false) { die ('Unable to find image'); } echo 'Opened image'; //Did we successfully open this image. Please note that for some reason when we do find the image. This disappears. If I comment out everything below. This shows up and says open image. When I attempt to display the image, this no longer outputs to the browser. function open_image($file) { // What extension are we working with? $extension = strrchr($file, '.'); $extension = strtolower($extension); switch($extension) { case '.jpg': case '.jpeg': $im = @imagecreatefromjpeg($file); break; case '.gif': $im = @imagecreatefromgif($file); break; case '.png': $im = @imagecreatefrompng($file); break; // ... etc ... etc ...etc (I did not include the rest here to keep this short) default: $im = false; break; } return $im; } imagepng($image); // Output to browser directly through GD Code however this doesn't return an image. ?> I have not programmed GD before so this is a learning process. Please help... Thanks, Wayne
  11. Okay, I have the file changed now with everything uncommented however I still have the error that as soon as the file goes to $image = open_image($image); it loses the picture 100%. any ideas? Wayne
  12. I have run into some issues on the computer on this end. It will not let me into FTP. I downloaded Filezilla and installed it, looked into the filezilla start menu and 30 viral infected files were inside the directory. I downloaded it from sourceforge so I am not sure what is happening. I will look into this first and then change that file. sorry for the delay.
  13. I will uncomment it but you will see some massive issues appear... lol I will have it uncommented in the next 2 minutes. Wayne
  14. Okay, that worked however now I get the following error. Unable to open image Any ideas
  15. I am having some issues with GD progamming. GD is available on our server already confirmed with our hosting company. Todays Goal: Clear up all issues with this php script below so it displays all requested images in all browsers. Ultimate Goal: Be able to resize images using GD based upon screen width detected with JavaScript. I have the JavaScript code for that as well and I will include it below if anyone needs it. Problem: All of the code is written and works to an extent. I cannot figure out where this error is coming from and why. I think it may have something to do with how my arrays are written but I am unsure. Specific Problem Area: $width = imagesx($image); //This is the problem area $height = imagesy($image); //This is the problem area Can someone please help? I am heading to work right now and will not be back until 10pm or 11pm EST. I can respond to anything than however I am leaving you with everything that I have. Thank you for any help. - Wayne Website: Computer Repair Sarasota, Bradenton, Venice OR http://67.199.62.141/ whichever you prefer. Location of my the images on my server: /images/ (The array below will show you what images I am attempting to utilize for this) PHP GD Code <?php function open_image ($file) { // Get extension $extension = strrchr($file, '.'); $extension = strtolower($extension); switch($extension) { case '.jpg': case '.jpeg': $im = @imagecreatefromjpeg($file); break; case '.gif': $im = @imagecreatefromgif($file); break; case '.png': $im = @imagecreatefrompng($file); break; // ... etc default: $im = false; break; } return $im; } //Creating an array $image = array("/images/scrfix-logo.png", "/images/shopping-cart.jpg", "/images/forums.jpg", "/images/sign-in.jpg", "/images/contactus.jpg", "/images/printer.jpg"); // Load image for ($i=0; $i<count($image); $i++) { $image = $image[$i]; open_image($image); if ($image === false) { die ('Unable to open image'); } // This passes with no problems // Get original width and height $width = imagesx($image); //This is the problem area $height = imagesy($image); //This is the problem area // Could this be because the array includes /images/ in it? //I have the below commented out because it causes massive problems with it uncommented. I am attempting to take care of 1 issue at a time. As soon as we clear up the above issue I will uncomment the rest of this and find out why those issues are happening. /* // New width and height $new_width = 150; $new_height = 100; // Resample $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Display resized image header('Content-type: image/jpeg'); imagejpeg($image_resized); die('Extreme Error'); */ echo "<img src='" . $image . "' />"; } ?> PHP and JavaScript Resolution Detection Code <?php //Set the variable to Self Page $url = $_SERVER['PHP_SELF']; //Test for the cookie on the users computer if(isset($HTTP_COOKIE_VARS["res"])) $res = $HTTP_COOKIE_VARS["res"]; //If no cookie found. Create the cookie and redirect to same page. else{ ?> <script language="javascript"> <!-- go(); function go() { var today = new Date(); var the_date = new Date("August 31, 2020"); var the_cookie_date = the_date.toGMTString(); var the_cookie = "res="+ screen.width +"x"+ screen.height; var the_cookie = the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location = '<?echo "$url";?>'; } //--> </script> <?php } ?> <?php //Let's "split" the resolution results into two variables list($width, $height) = split('[x]', $res); //Take the width and height minus 300 $tb_width = $width-300; // This can be changed to whatever such as decimals (ie. 0.75). $tb_height = $height-300; // This can be changed to whatever such as decimals (ie. 0.75). //Make the table //This is here only to test the code and show that it works. The GD code above will go in its place print("<table align=center border=1 width=" .$tb_width . " height=" . $tb_height . " > <tr><td align=center>Your screen resolution is " . $width . " by " . $height . ".<br> The width/height of this table is " . $tb_width . " by " . $tb_height . ".</td></tr> </table>"); ?>
  16. Okay, Now presuming that both domains are on different servers, how do I get domain A to use domain B's header file? I was also looking into the header() function. header('Location: http://www.example.com/'); I figure worse case scenario, I should be able to store a reference in a database table and have the domain A access the database and utilize the reference however I don't know if that will work either. That is what I am attempting to find out here. Thanks for the quick response. Wayne
  17. I know what a domain is but I don't see the answer.
  18. Is is possible to have two domains with the same header and footer files stored on 1 domain? I have attempted the require_once('') and the include('') via the http protocol and I cannot get the header to show up. It doesn't even pay attention to the PHP code. It merely ignores it. If this is possible how would I do this? Should I store a reference to it in a database and have it called from the database or is there an easier way? Thanks, Wayne
  19. I have Windows Vista, IIS7. I downloaded and installed PHP 5.25 using the Windows Installer. I want to use ISAPI module. I followed the instructions on the following website: http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx However, when I attempt to check to see if this is going to work I open IE and go to c:/inetpub/SCRFix/home.php instead of seeing the webpage it just attempts to bring up a download box as if I was downloading a file. Any ideas? Thanks, Wayne
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.