Solved

Optimize GAL Photos from AD using Script

Posted on 2014-04-29
3
292 Views
Last Modified: 2014-05-06
Ok so I have a folder with all my photos that I want to add to AD and Outlook to appear on emails.  I know I have to optimize each photo to be less than 100x100.  I found a free tool ImageMagik and a PS1 to use although Im unsure what I change in the PS1 to get it to work:

My folder is C:\security photos\atlanta
The new pics cna be written to folder:  C:\ad photos\atlanta


Here is the PS1 where do I change the input and output folders to the above to get this to work?  Thanks

param($InputFolder,$OutputFolder,$Quality);
# GALBatchConvert.ps1
# Use to convert large numbers of contact pictures to optimised 96x96 GAL photos
#
# Steve Goodman
if (!$InputFolder -or !$InputFolder)
{
    throw "InputFolder and OutputFolder parameters are mandatory";
}
if (!(Test-Path $InputFolder))
{
    throw "InputFolder not found";
}
if (!(Test-Path $OutputFolder))
{
    throw "OutputFolder not found";
}
$FullOutputFolderPath = (Get-Item $OutputFolder).FullName
if (!$Quality)
{
    $Quality = 50;
}
$Items = Get-ChildItem $InputFolder
if ($Items.Count -eq 0)
{
    throw "No items in folder"
}
[array]$ValidExt=".jpg",".jpeg",".bmp",".tif",".tiff",".gif",".png"
foreach ($Item in $Items)
{
    if ($ValidExt -contains $Item.Extension)
    {
        Write-Output "Converting $($Item.FullName)"
        .\convert.exe -quality $Quality -depth 8 -strip -thumbnail 96x96^ -gravity Center -crop 96x96+0+0 $Item.FullName "$($FullOutputFolderPath)\$($Item.BaseName).jpg"
    }
}
0
Comment
Question by:Twhite0909
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 40031357
You're supposed to pass them into the script as arguments (the param block dictates this).

That is, if you had the above saved as fix-pictures.ps1, you'd run:
c:\somewhere\fix-pictures.ps1 -InputFolder "C:\Source" -OutputFolder "C:\Destination"

Open in new window

Quality is set to 50 if you don't set it to something else. If you needed to change that too it would become:
c:\somewhere\fix-pictures.ps1 -InputFolder "C:\Source" -OutputFolder "C:\Destination" -Quality 75

Open in new window

Finally, if PowerShell complains about not being able to execute unsigned code, you should review "Get-Help about_Code_Signing" then consider running:
Set-ExecutionPolicy RemoteSigned

Open in new window

Cheers,

Chris
0
 

Accepted Solution

by:
Twhite0909 earned 0 total points
ID: 40034530
I used a free tool called Infraview
0
 

Author Closing Comment

by:Twhite0909
ID: 40043941
BC I was right lol
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A hard and fast method for reducing Active Directory Administrators members.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question