title: PowerShell - Reduces the size of images
body: <p>I try to make a script that reduces the size of images in a folder. But I have always a error message. 
  I must reduce the size in the same folder and subfolders</p>
  
  <p>Can you help to build my script please?</p>
  
  <p>Thank you in advance.</p>
  
  <p>Here is the script :</p>
  
  <pre><code>$source = "U:\TEST\Compression\images"
  $exclude_list = "(Imprimerie|Photos)"
  
  $source_listephotos = Get-ChildItem $source -Recurse | where {$_.FullName -notmatch $exclude_list}
  
  foreach ( $source_photos in $source_listephotos ) {
  
  $source_photos
  
  Resize-Image -InputFile $source_photos.FullName -Scale 30 -OutputFile (Join-Path $source $source_photos.Name) -Verbose
  
  }
  </code></pre>
  
  <p>And here the error message :</p>
  
  <pre><code>    Exception calling "Save" with "1" argument(s): "A generic error occurred in GDI+."
  At C:\windows\system32\windowspowershell\v1.0\Modules\Resize-Image\Resize-Image.psm1:70 char:9
  +         $img2.Save($OutputFile);
  +         ~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : ExternalException
  </code></pre>