WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: hienpham on January 15, 2015, 11:22:23 AM

Title: Importing JPEG file to thumbnailPhoto in the Active Directory
Post by: hienpham on January 15, 2015, 11:22:23 AM
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.
Title: Re: Importing JPEG file to thumbnailPhoto in the Active Directory
Post by: JTaylor on January 15, 2015, 12:01:09 PM
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
Title: Re: Importing JPEG file to thumbnailPhoto in the Active Directory
Post by: td on January 15, 2015, 12:09:40 PM
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
Code (winbatch) Select

; 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. 
Title: Re: Importing JPEG file to thumbnailPhoto in the Active Directory
Post by: td on January 15, 2015, 01:15:19 PM
Here's a script snippet that adds a thumbnail photo using the ADSI extender

Code (winbatch) Select

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)
Title: Re: Importing JPEG file to thumbnailPhoto in the Active Directory
Post by: hienpham on January 15, 2015, 01:18:51 PM
Thanks TD and JTaylor,
  WinBatch and your help make my job really easy.

Thanks so much.
hienpham