title: errors keep cropping up implementing a basic phpthumb script...Permission denied on line 1070 of GdThumb.in.php
body: <p>I wanted a script that automatically generates thumbnails when from a folder full of larger images. I've ran into some problems implementing it.</p>
  
  <p>I was getting some errors early on because I hadn't included all the phpthumb files i needed, but now the errors are coming from within the phpthumb code itself. Will post more code as needed.</p>
  
  <p>The errors:</p>
  
  <pre><code>Warning: getimagesize(.\.) [function.getimagesize]: failed to open stream: Permission denied in C:\xampp\htdocs\mysite\GdThumb.inc.php on line 1070
  
  Fatal error: Uncaught exception 'Exception' with message 'File is not a valid image: .\.' in C:\xampp\htdocs\mysite\ThumbBase.inc.php:193 Stack trace: #0 C:\xampp\htdocs\mysite\GdThumb.inc.php(1081): ThumbBase-&gt;triggerError('File is not a v...') #1 C:\xampp\htdocs\mysite\GdThumb.inc.php(98): GdThumb-&gt;determineFormat()
  #2 C:\xampp\htdocs\mysite\ThumbLib.inc.php(127): GdThumb-&gt;__construct('.\.', Array, false) #3 C:\xampp\htdocs\mysite\save_differentformat.php(47): PhpThumbFactory::create('.\.') #4 {main} thrown in C:\xampp\htdocs\mysite\ThumbBase.inc.php on line 193
  </code></pre>
  
  <p>the script:</p>
  
  <pre><code>require_once '../mysite/ThumbLib.inc.php';
  
  $dir = "../mysite/images" ;
  $destination = "../mysite/thumbnails" ;
  $images = scandir($dir);
  
  foreach ($images as $image)
  {
      $ext = pathinfo($dir . DIRECTORY_SEPARATOR . $image,PATHINFO_EXTENSION);
      $thumb = PhpThumbFactory::create($image  . DIRECTORY_SEPARATOR. $image);
      $thumb-&gt;adaptiveResize(100, 100);
      $thumb-&gt;save($destination . DIRECTORY_SEPARATOR. $image, $ext);
      $thumb-&gt;show();
  }
  ?&gt;
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's the error messages i'm getting right now. It doesn't know what $mode is and i may have a mix of image types in that folder.</p>
  
  <pre><code>Notice: Undefined variable: mode in C:\xampp\htdocs\mysite\save_differentformat.php on line 51
  
      Warning: getimagesize(.\.) [function.getimagesize]: failed to open stream: Permission denied in C:\xampp\htdocs\mysite\GdThumb.inc.php on line 1070
  
      Fatal error: Uncaught exception 'Exception' with message 'File is not a valid image: .\.' in C:\xampp\htdocs\mysite\ThumbBase.inc.php:193 Stack trace: #0 C:\xampp\htdocs\mysite\GdThumb.inc.php(1081): ThumbBase-&gt;triggerError('File is not a v...') #1 C:\xampp\htdocs\mysite\GdThumb.inc.php(98): GdThumb-&gt;determineFormat()
      #2 C:\xampp\htdocs\mysite\ThumbLib.inc.php(127): GdThumb-&gt;__construct('.\.', Array, false) #3 C:\xampp\htdocs\mysite\save_differentformat.php(64): PhpThumbFactory::create('.\.') #4 {main} thrown in C:\xampp\htdocs\mysite\ThumbBase.inc.php on line 193
  </code></pre>
  
  <p>Here's what scandir() is returning:</p>
  
  <pre><code>array(19) { [0]=&gt; string(1) "." [1]=&gt; string(2) ".." [2]=&gt; string(36) "13912d3e8b4ae1890457fe935cc0c7fe.png" [3]=&gt; string(36) "266c484ca488d053255c7767af212bee.png" [4]=&gt; string(36) "8af941c37874dc3a7edee2772b60c323.png" [5]=&gt; string(9) "Thumbs.db" [6]=&gt; string(15) "butterflies.png" [7]=&gt; string(22) "butterfliesinverse.png" [8]=&gt; string(11) "favicon.png" [9]=&gt; string(36) "fb9e25f57d12ec5019aa548665f34fa5.png" [10]=&gt; string(20) "image1.png" [11]=&gt; string(25) "image11 (1).png" [12]=&gt; string(21) "image11.png" [13]=&gt; string(25) "image12 (1).png" [14]=&gt; string(21) "image12.png" [15]=&gt; string(21) "image15.png" [16]=&gt; string(20) "image2.png" [17]=&gt; string(21) "image25.png" [18]=&gt; string(21) "image28.png" }
  </code></pre>