Hi,
We have thousands of JPEG files from the employee pictures that we want to import to the corresponding thumbnailPhoto attribute. For that we need to resize those pictures and then do the import. We want to automate those steps using WinBatch.
Could you give me a hint about how to:
1. to do the resize
2. and do the import
We don't have any problem to get to the thumbnailPhoto attribute of the owner of the picture.
(BTW I have read the "Converting Active Directory Thumbnailphotos to File" WinBatch article, my goal is to do the inverse (put the picture in))
Thanks for any help.
I recommend using the ImageMagick COM interface for doing the resizing. There is a native extender for Image manipulation but the quality of the results will be far inferior to ImageMagick.
Jim
One of many alternatives for resizing can be found here
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Samples~from~Users+GDI~Image~Resize.txt (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Samples~from~Users+GDI~Image~Resize.txt)
Adding a thumbnail is much like fetching one
; Using our test server with a dummy account.
AdSIPath = "LDAP://shamrock/CN=BOB Smith,CN=Users,DC=jclass,DC=org"
objUser = ObjectGet(AdSIPath)
strJpg = "C:\bitmaps\intrepid_pic.jpg" ; Your image goes here.
nSize = Filesize(strJpg) + 64
hJpg = BinaryAlloc(nSize)
BinaryRead( hJpg, strJpg )
BinaryOleType( hJpg, 103 , 0, 0, 0)
objUser.Put("thumbnailphoto", hJpg)
objUser.SetInfo
BinaryFree(hJpg)
The latter can be done with the ADSI extender as well.
Here's a script snippet that adds a thumbnail photo using the ADSI extender
AddExtender('wwads44i.dll',0,'wwads64i.dll')
InFile = 'c:\Bitmaps\MyIcon.jpg' ; Your image.
UserPath = "LDAP://shamrock/CN=Bill Bates,CN=Users,DC=jclass,DC=org" ; Your user path.
; Load the image.
hIn = BinaryAlloc(FileSize(inFile)+128)
BinaryRead(hIn, InFile)
strHexPhoto = BinaryPeekHex(hIn, 0,BinaryEodGet(hIn))
BinaryFree(hIn)
; Add the image to the user account.
dssetproperty(UserPath," thumbnailphoto ", strHexPhoto)
Thanks TD and JTaylor,
WinBatch and your help make my job really easy.
Thanks so much.
hienpham