0 votes

I'm wondering if there is anyway to allow for re-sizing of a user picture? For example, a new employee starts and HR takes their photo on a digital camera, resulting in a 2-3mb file. Is there anyway they can upload that and have Adaxes compress that down to ~20k? Currently when I try to upload a bigger photo I get an error message. What are the current specs that a picture has to meet for Adaxes to process it?

I'd like to avoid my users having to run the photo through a separate process first for re-sizing, it would be great if it could all happen in the background once they select it in Adaxes.
Thanks
Ryan

by (920 points)
0

Hello Ryan,

In the version that will follow Adaxes 2014.1, we are going to completely rework the look and feel of Adaxes Web interface. In that version, we are going to provide some basic functionality for editing uploaded pictures, and resizing picture is among the features that we are going to introduce.

For now, it is possible to use a PowerShell script for this purpose. You can add a certain field on the Web interface that will be used to input the image file name. For this purpose, you can use one of Adaxes virtual properties that can store string (text) values. Such properties are not stored in Active Directory, but can be used as any other property of AD objects. A Business Rule triggered after updating a user will read the file at the specified file path and process the image to fit within the limitations, then save the image to the Picture property.

As for the actual resizing, there are multiple ways how this can be implemented in PowerShell code. For example, you can use some sort of an image processing tool, like ImageMagick, for example, and pass the picture to the tool from command line. Alternatively, it is possible to use a PowerShell module for this purpose, for example, the PSImageTools from the Windows 7 Resource Kit. Also, it is possible to use the native .Net functions to manipulate the image, however it'll take longer to develop the script.

If such a solution is OK with you, we will help you with a script.

0

Can you give me some more specifics on how to use a virtual text property for this? Will I need to type a unc path to the photo and have the user store the photo somewhere the adaxes service has permissions to read, or would it be possible to get an open file dialog and browse for the file that way?

I'm thinking the PSImageTools module would be easiest. Would you be able to give me instructions on how to load that module onto the Adaxes server (server is running Windows 2012 R2 if that matters). If you could help with a script that would be wonderful!

Thank You!
Ryan

0

Hello Ryan,

Can you give me some more specifics on how to use a virtual text property for this? Will I need to type a unc path to the photo and have the user store the photo somewhere the adaxes service has permissions to read, or would it be possible to get an open file dialog and browse for the file that way?

There won't be a file dialog to select a file, users will have to type in or paste a path to the file with the picture. The file needs to be saved on a certain share that can be accessed from the computer where Adaxes is installed.

I'm thinking the PSImageTools module would be easiest. Would you be able to give me instructions on how to load that module onto the Adaxes server (server is running Windows 2012 R2 if that matters). If you could help with a script that would be wonderful!

Yes, of course we will help you. Will an option with a text field be sufficient?

0

Yes, a text field for the file path will work.

Thanks!

0

Hello Ryan,

OK, we've asked our script guys to write a script for you. We will update you as soon as they come up with something.

0

Hello Ryan,

Our script guys have encountered a small issue with a script for you.

The thing is that PSImageTools won't work on a Server edition of Windows because the module relies on the Windows Image Acquisition (WIA) Service, which is not installed by default on Server editions of Windows. It is, of course, possible to install it additionally, however the Service is installed by enabling the Desktop Experience feature in Windows. Among other things, it transforms the interface of Windows Server 2012 (r2) into the interface of Windows 8 (8.1) and installs some additional 'user experience' features that you'd probably not like to have on a Server edition of Windows.

Are you OK with using ImageMagick?

0

Sure, we can try ImageMagick.
Thanks.
Ryan

0

Ryan,

OK, our script guys are already working on a script :)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello Ryan,

The script is ready. To be able to use it with Adaxes, you'll need to create a Business Rule. For example, to set a picture after a user is created, you'll need to create a Business Rule that runs the script after creating a user. For more details, see Run PowerShell Script after Creating a User.

The script reads the file path from the CustomAttributeText1 property. To allow users specify the file path in the Web interface, you need to add it to the forms for creating or editing a user. For information on how to do this, see step 6 in the following tutorial: http://www.adaxes.com/tutorials_WebInte ... diting.htm.

In the script, $programPath specifies the full path to the Convert.exe executable that will do the actual resizing. It is a part of the ImageMagick suite and must be installed on the same computer where Adaxes service is installed.

The script:

$programPath = "C:\Program Files\ImageMagick\Convert.exe" # TODO: modify me

try
{
    $filePath = $Context.TargetObject.Get("adm-CustomAttributeText1")
}
catch
{
    return # The property is empty
}

# Try read the user photo
try
{
    $thumbnailPhotoBytes = [System.IO.File]::ReadAllBytes($filePath)
}
catch
{
    $Context.LogMessage("Error reading file: " + $_.Exception.Message, "Error")
    return
}

# Write the photo to a temporary file
$tmpFilePath = [System.IO.Path]::GetTempFileName()
[System.IO.File]::WriteAllBytes($tmpFilePath, $thumbnailPhotoBytes)

# Launch an external program to resize the photo
& $programPath "$tmpFilePath" -resize 80x80^ "$tmpFilePath" 

# Wait 5 seconds
Start-Sleep -Seconds 5

# Read the modified file
$thumbnailPhotoBytes = [System.IO.File]::ReadAllBytes($tmpFilePath)

# Set the modified photo to user properties
$Context.TargetObject.Put("thumbnailPhoto", $thumbnailPhotoBytes)

# Delete the temporary file
[System.IO.File]::Delete($tmpFilePath)

# Clear CustomAttribute
$Context.TargetObject.Put("adm-CustomAttributeText1", $NULL)

# Save changes
$Context.TargetObject.SetInfo()
0

Thanks so much!

Related questions

0 votes
1 answer

Hello, Could you help me with a script to save the picture attribute from a targeted user to a temporary jpg file named employeeid.jpg, and then move that jpg to a network file share? Thanks so much! Ryan

asked May 21, 2014 by ryan_breneman (920 points)
0 votes
1 answer

My HR deparment has the ability to export users with managers report to Excel, however the user's picture in embeded into the name column and there is no way to remove it from the report nor from the Excel exported file. Please help.

asked Aug 29 by jurbina (40 points)
0 votes
1 answer

Or is there another solution to solve this?

asked Sep 15, 2022 by boris (550 points)
0 votes
1 answer

Is it possible for the approval email to display the picture? I've been unable to find the configuration panel for this process. Attached is the message we receive.

asked Mar 2, 2020 by kcd (20 points)
0 votes
1 answer

Is it possible to use the AD profile image in an external application? I was using "ObjectImage.ashx?path={AD Path}" till the previous version to get the profile images in my web application. But since the upgrade to 2018.2 this doesn't seem to be an option.

asked Nov 28, 2018 by sdavidson (730 points)
3,588 questions
3,277 answers
8,303 comments
548,084 users