title: Error on imagecreatefromjpeg() function php
body: <p>I am trying to run the below code in W3shcools phptryit page but I get this error:</p>
  <blockquote>
  <p>PHP Fatal error: Uncaught Error: Call to undefined function
  imagecreatefromjpeg() in /home/LPmJMe/prog.php:26 Stack trace: #0
  /home/LPmJMe/prog.php(35): resize_image('data:image/jpeg...', 100,
  100) #1 {main} thrown in /home/LPmJMe/prog.php on line 26</p>
  </blockquote>
  <pre><code>function resize_image($file, $w, $h, $crop=FALSE) {
      list($width, $height) = getimagesize($file); 
      $r = $width / $height;
          if ($crop) {
              if ($width &gt; $height) {
                  $width = ceil($width-($width*abs($r-$w/$h)));
                   
              } else {
                  $height = ceil($height-($height*abs($r-$w/$h)));
              }
              $newwidth = $w;
              $newheight = $h;
          } else {
              if ($w/$h &gt; $r) {
                  $newwidth = $h*$r;
                  $newheight = $h;
              } else {
                  $newheight = $w/$r;
                  $newwidth = $w;
              }
              }
          $src = imagecreatefromjpeg($file);
          $dst = imagecreatetruecolor($newwidth, $newheight);
          imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
          echo $newheight;
      $filename= basename($file,&quot;.jpg&quot;);
      $file=$filename.'-'.$w.'x'.$h.'jpg';
  }
  $w=100;
  $h=100;
  resize_image($file, $w, $h);
  </code></pre>