Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Optimize GAL Photos from AD using Script

Posted on 2014-04-29
3
Medium Priority
?
305 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
how to add IIS SMTP to handle application/Scanner relays into office 365.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

664 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