Is it possible to batch upload user profile images in Confluence?

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2013

I'm aware of the restrictions and improvement request for allowing administrator's to change a user profile's picture (hey, Atlassian, fix that already!). In the meantime, is there some way to do this in the back-end? Perhaps through the command line interface or a plugin?

3 answers

1 accepted

2 votes
Answer accepted
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2013

Works on my machine

Small disclaimer: this works great on my setup. I have not tested it outside of my setup. It should work just fine as I am using the standard API's that come with Confluence, but it is an open source project and I'm not getting paid for it, so I haven't done extensive testing in all scenarios.

That said, here is a utility I created to upload user photos in batch. You can get the source here ...
https://bitbucket.org/fredclown/confluence-profile-photo-uploader

The compiled binary is here...
https://bitbucket.org/fredclown/confluence-profile-photo-uploader/downloads/ConfluenceProfilePhotos.zip

Basically you supply the program with a folder where the user photos are. It will pull in all the .jpg,.jpeg, .tif, .tiff, .png, and .bmp files in the folder. The photos should be in this format username.png, username.jpg, etc. Since Confluence profile photos are 48x48 and most photos are not square it will do face detection and then crop the photo unless you specify otherwise(via a checkbox). It has a form mode (just click on the executable) and a headless mode (supply the command line arg /headless) for automating the process. Hope this helps you out.

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2013

Hi Davin,

This looks really cool and how good of you to go out of your way to produce such a fine looking program for free. I'll give you the kudos now (before using it) as I need to do some things first.

Awesome!

Steve

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2013

OK, unfortunately I couldn't get it to work. I supplied with the correct information, photos, etc. But I get the following error:

"System.InvalidOperationException: Client found response content type of 'text/html; charset=UTF-8', but expected 'text/xml'.

The rest of error message I can't get to because of the odd way the error message is returned. Any ideas?

Thanks

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2013

Hmmm ... shoot. :) Would you be able to let me see what is in the ConfluenceProfilePhotos.exe.config file ... minus the encrypted password line? Also, do you have Confluence behind a reverse proxy or are you accessing the Tomcast server directly? Lastly, what OS is the server? Oh also, do you have the "Remote API" feature turned on under Confluence Admin -> General Configuration? If you want an address to email the config file you could send it to fredclown at gmail.

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 16, 2013

Thanks, Davin. I've sent you an email.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2013

Looks like the issue had to do with the SOAP API plugin. Once that was fixed the upload utility worked.

Steve Goldberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2013

OK I have used Davin's program and I can report that it is exactly what I wanted. Once the issues with the SOAP interface was resolved it worked like a charm. It uploaded them quickly and efficiently and I didn't notice any significant performance problems during the process.

Excellent program!

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2015

Just released v1.1.0.0. It does better face detection and cropping, has a version checker, and a test harness to see how the system will crop and resize your photos.

Najmeddine Othmani May 22, 2019

Hi @Davin Studer 
I’m trying to bulk upload images for Confluence using  Confluence Profile Photo Uploader v1.3.0.0 and I’m receiving this error :

System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

 

   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)

 

   at Emgu.CV.CvInvoke..cctor()

 

   --- End of inner exception stack trace ---

 

   at Emgu.CV.Image`2..ctor(String fileName)

 

   at VanClinic.Utilities.ConfluenceProfilePhotos.PhotoUpload.UploadPhoto(String Photo) in C:\conf photo updater\PhotoUpload.cs:line 218

 

 

Please can you help me with this and I would like to know which version of EmguCV library did you use

1 vote
Masahito Shimauchi March 18, 2014
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2014

Action is: addUserPicture

0 votes
Andrew Franklin Leo Palu Pillai March 12, 2014
#!/usr/bin/python
# BulkPhotoUpload.py
#Script to read *.png files from a directory and upload as profile picture for users

import os
import shutil
import fnmatch
import xmlrpclib
import string
import re

#Function to generate files that match a given filename pattern with in a directory
def get_files_in_directory(filepat,top):
    for path, dirlist, filelist in os.walk(top):
        for userphoto in fnmatch.filter(filelist,filepat):            
            yield os.path.join(path,userphoto)

#Main Function
if __name__ == '__main__':
    #Source Directory must be specified
    source = 'C:\BulkPhotoUpload\UserPhotos' # From where pictures of the users are read
    #Destination Directory must be specified
    destination = 'C:\BulkPhotoUpload\Archive' # To where pictures of the users are archived after uploading
    #The confluence server must be specified and the XML-RPC API must be enabled in the system
    server = xmlrpclib.ServerProxy('http://localhost:8090/rpc/xmlrpc')
try:
    #Must specify the UserName & the Password of the usercontext on which the operation must be performed
    token = server.confluence1.login('username', 'password');
    #Gets all the PNG files from the directory
    userphotocollection = get_files_in_directory("*png",source)
    #Iterate the files to upload them as profile photo for users
    for userPhoto in userphotocollection:        
        pictureData = xmlrpclib.Binary(open(userPhoto,'rb').read())
        picName = os.path.basename(userPhoto)         
        userName = os.path.splitext(picName)[0]        
        profilePictureAdded = server.confluence1.addProfilePicture(token, userName, picName, 'image/png', pictureData)
    if profilePictureAdded:
        #Move the uploaded images to the Archive directory        
        print "Successfully added profile picture for %s" % userName
        shutil.move(userPhoto, destination)
    else:
        print "Failed to add profile picture for %s" % userName        
except xmlrpclib.Fault, err:
    print "Fault code: %d" % err.faultCode
    print "Fault string: %s" % err.faultString

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events