Upload images from folder to a program by powershell

Its like, I have a folder containing 2000+ jpg images and have folders somewhere with name 1, 1.33, 1.5, 2 with are basically ratio names. I want if powershell could upload those images and crop them according to the closest aspect ratios(1, 1.33, 1.5, 2) and save into respective ratio folder.

Or tell this software JPEGCrops to upload image and use its functions to crop image to closest ratio and save to respective ratio 1, 1.33, 1.5, 2 folder.

if you are not able to understand, its like:

powershell uploads images from "C:\images\" folder

check each image' ratio, by width/height

if(ratio is closest to any 1, 1.33, 1.5, 2 ) crop into that

then save it into respective 1, 1.33, 1.5, 2 folder.
 

My Computer

Hello busybee235 and welcome to the forums :party:

Are they all grouped into aspect ratios as they are? Say 400 at 1.4, 250 at 1.33 etc. Or is every file different? If there's less than 10 (give or take a few) different aspect ratios, I think I can help.

Please ignore this, I just don't want to lose the link: http://sumtips.com/2011/12/sort-organize-images-resolution-aspect-ratio.html

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
thanks tom for replying.

All 200+ images are unsorted and mixed in a folder with mixed ratio and that too different other than mentioned (1,1.33,1.5,2) ratios.
 

My Computer

No worries :) My C# is very rusty, but I might just be able to code this for you if I have to. There are easier solutions that I would like to try first.

Of those 200+ images, how many different aspect ratios are there?
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
Each image has different aspect ratio. I want if powershell can move those files which are closest to the mentioned ratio folder(1,1.33,1.5,2). It goes on checking each image and move them to appropriate folder. This is just powershell requirement.

for eg. 1 image has dimension(1366 x 768) width x height

so it has ratio 1366/768=1.78
Now script should compare this ratio(1.78) with all the ratios(1,1.33,1.5,2) and find closest to it i.e. 2, then it should move that image to the folder named 2.

Its simpler than using and uploading into any other program.
 

My Computer

Each image has different aspect ratio. I want if powershell can move those files which are closest to the mentioned ratio folder(1,1.33,1.5,2). It goes on checking each image and move them to appropriate folder. This is just powershell requirement.

for eg. 1 image has dimension(1366 x 768) width x height

so it has ratio 1366/768=1.78
Now script should compare this ratio(1.78) with all the ratios(1,1.33,1.5,2) and find closest to it i.e. 2, then it should move that image to the folder named 2.

Its simpler than using and uploading into any other program.

Hello busybee,

I'll give it a go, but I can't promise anything. I'm going to have to learn a little powershell to do this! I found a great script to get the image properties:

Code:
[System.Reflection.Assembly]::LoadFile( "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll")  
  
 "Name|SizeInBytes|Width|Height" >> C:\JPGInfo.txt  
  
 $path = "C:\Images\"  
 $images = Get-ChildItem -Recurse $path -Include *.jpg  
  
 foreach ($image in $images)  
 {  
     $name = $image.Name  
     $length = $image.Length  
     $imageFile = [System.Drawing.Image]::FromFile($image.FullName) 
     $width = $imageFile.Width  
     $height = $imageFile.Height 
  
     "$name|$length|$width|$height" >> C:\JPGInfo.txt  
      
     $imageFile.Dispose() 
 }
Source: Capturing Image Attributes - PowerShellCommunity.org - Windows PowerShell Discussion Forums - Using PowerShell - Working with .NET

[del]Now I need to modify that to calculate the aspect ratio and sort out the directories, then upload the lot. Where do you want to upload these images to?[/del]

Edit: What am I talking about, this is way above me :( I don't have time to teach myself Powershell. I hope you get a reply here though:

http://powergui.org/thread.jspa?threadID=19501

This should go on until the last image in source folder.

Sorry, for repetition.

No worries :)

Tom
 

My Computer

System One

  • Manufacturer/Model
    Build #1
    CPU
    Intel Core i7 3770K @4.4GHz
    Motherboard
    ASUS P8Z77-V PRO
    Memory
    Corsair Vengeance 2x4GB DDR3 1600MHz Low Profile (White)
    Graphics Card(s)
    Gigabyte Radeon HD 7850 (2GB GDDR5)
    Sound Card
    Integrated on motherboard
    Monitor(s) Displays
    23" LG LCD/LED IPS
    Screen Resolution
    1920*1080
    Hard Drives
    Samsung EVO 128GB SSD
    Seagate Barracuda 2TB 7200rpm
    2x500GB Seagate FreeAgent 5400rpm
    PSU
    Corsair TX650W V2 (80+ Bronze)
    Case
    NZXT Phantom 410
    Cooling
    Corsair H100 Water Cooler, 1x140mm and 1x120mm stock fans
    Keyboard
    Microsoft Desktop 2000 Wireless Keyboard
    Mouse
    Microsoft Desktop 2000 Wireless Mouse
    Internet Speed
    95 Mb/s Download 70 Mb/s Upload
Back
Top