Jump to content

opoohwan

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

opoohwan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I actually figured it out. the problem was that I put the wrong variables into the function. the last to bits of information was supposed to be the original images height and width, instead I had the new images. corrected code. imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbHeight, $thumbWidth, $origHeight, $origWidth); original incorrect code imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbHeight, $thumbWidth, imagesy($thumbImg), imagesx($thumbImg));
  2. opoohwan

    isset

    You can define the variable through a $_POST. Say you had a form that collected the name of the user, and you wanted to call the user by name. you could pass the information from the form to the next php page using $_POST.
  3. opoohwan

    isset

    By asking if $_POST['$name'] is set you are asking for php to pull something from a form that you sent using a post variable. instead you are defining the variable on the same page. try this. <?php $name = "Danielson"; if (isset($name)) { echo ("<h2> Hi, my name is " .$name.".</h2> <br />"); } else { echo ("I'm confused!"); } *looks like phpdragon beat em to it and explained it better*
  4. I probably worded the question wrong. Basically the code I wrote will take a 1000x1000 image and crop a 100x100 square from the image, instead of creating a 100x100 thumbnail. Any suggestions?
  5. I am creating my first CMS using PHP. for this feature, I want to allow a user to upload an image and PHP will upload the image, then also create a thumbnail of either 100px width or 100px height (depending on if it is portrait or landscape orientation). So far I have only one problem. The GD Function imagecopyresized will create the thumbnail for me, but instead of it being the larger image shrunk to the new size, it creates a cropped version of the larger on in the new size. here is the code please help. it is way over my head. in the original file (calling from an included function.php) createThumbnail("uploadedimages", "$image", "uploadedimages/thumbs", 100); in the function.php page function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $value) { $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); $origWidth = imagesx($srcImg); $origHeight = imagesy($srcImg); if($origWidth > $origHeight) { $thumbWidth = $value; $ratio = $thumbWidth / $origWidth; $thumbHeight = $origHeight * $ratio; $thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight); imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, imagesx($thumbImg), imagesy($thumbImg)); imagejpeg($thumbImg, "$thumbDirectory/$imageName"); }else{ $thumbHeight = $value; $ratio = $thumbHeight / $origHeight; $thumbWidth = $origWidth * $ratio; $thumbImg = imagecreatetruecolor($thumbHeight, $thumbWidth); imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbHeight, $thumbWidth, imagesy($thumbImg), imagesx($thumbImg)); imagejpeg($thumbImg, "$thumbDirectory/$imageName"); } }
×
×
  • 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.