Resize-Image A PowerShell script to resize image files

A PowerShell module to resize image filesThis function uses the native .NET API to resize an image file, and optionally save it to a file or display it on the screen. You can specify a scale or a new resolution for the new image. It can be used interactively or as part of a scr

 
 
 
 
 
3.5 Star
(4)
13,305 times
Add to favorites
3/31/2015
E-mail Twitter del.icio.us Digg Facebook
  • Modified version
    1 Posts | Last post September 13, 2019
    • I modified this script to allow for proportional resizing and original file overwriting. I'm putting a link here to the paste and if I get around to it, I'll add it to TechNet.
      https://pastebin.com/YB2sY3Cj
  • Some how it randomly rotates counter clock wise 90 degrees, any idea?
    1 Posts | Last post February 16, 2018
    • When I run this, it randomly rotates the image 90 degrees counter-clockwise, any ideas?
  • not a question
    1 Posts | Last post January 18, 2018
    • just a thank you ,very cool script!
  • Saving to a file
    3 Posts | Last post February 21, 2017
    • For some reason when you execute the following command:
      
      Resize-Image -InputFile "C:\kitten.jpg" -Scale 30 -OutputFile "C:\kitten2.jpg"
      
      The output file fails to be generated. Any ideas?
    • I am getting the same thing.  No output being generated.  I want my money back.
    • I had to specify an InputFile and an Output file. They could not be the same name, so I put them into separate folders.
  • Comment
    1 Posts | Last post July 05, 2016
    • Just a comment, I modified the module to close the original image file after resize and save, as I was trying to move-item after a resizing in a foreach loop and file was locked. 
      
      add this code after the Save image section:
      
      # Close Image File
          $img2.Dispose()
          $img.Dispose()
      
       
  • Image resize
    1 Posts | Last post February 09, 2016
    • I have an image that is 500x500. I need to resize this to 120x160. When I try the script it keeps the size at 120x120. How do I resize the image to 120x160.Thanks. 
  • Output size
    2 Posts | Last post December 05, 2015
    • When I try to resize image (with scale = 50), output size is increased. Why??? Original file size is 2,85MB and output file is 3,58MB. When I do the same in Paint, resized file length is 450kb (expected value).
    • Probably because you're using a compressed JPEG. See this: http://stackoverflow.com/questions/24979017/how-to-resize-an-image-with-system-drawing-and-lower-the-image-size
      
      This module is more for occasional image work, with the ability to actually see the result on the screen. If you need more flexibility I highly suggest using ImageMagick which has the same abilities and will give you the proper file size when dealing with compressed formats. It just won't show it to you on the screen.
  • Thanks for Sharing! How do I batch resize all images in folder_1 output to folder_2 by percentage?
    2 Posts | Last post October 30, 2015
    • How do I batch resize all images in folder_1 output to folder_2 by percentage?
    • Could do something like:
      
      ls *.jpg | foreach { Resize-Image -inputfile $_ -scale 30 -outputfile $_ }