def get_mosaic_from_username(username, client_id, client_secret, number_of_photos=50): profile_filename_path = get_profile_photo_from_username(username) print "Profile photo at: " + profile_filename_path folder_images, filenames = download_user_images(username, my_client_id, my_client_secret, number_of_photos=number_of_photos) print "Downloaded images at: " + folder_images images_with_path = [] prev_path = folder_images + "/" for img in filenames: images_with_path.append(prev_path + img) profile_image = profile_filename_path profile_mosaic_path = profile_filename_path.replace(".jpg", "_mosaic.jpg") print "Creating mosaic at: " + profile_mosaic_path # TODO: parametrize and at least do 3 settings of mosaicify (tiles and zoom) # also probably paralellized creation of them with names corresponding to the quality osaic.mosaicify( target=profile_image, sources=images_with_path, tiles=128, zoom=8, output=profile_mosaic_path, ) return profile_mosaic_path
def get_mosaic_from_username(username, client_id, client_secret, number_of_photos=50): profile_filename_path = get_profile_photo_from_username(username) print "Profile photo at: " + profile_filename_path folder_images, filenames = download_user_images( username, my_client_id, my_client_secret, number_of_photos=number_of_photos) print "Downloaded images at: " + folder_images images_with_path = [] prev_path = folder_images + "/" for img in filenames: images_with_path.append(prev_path + img) profile_image = profile_filename_path profile_mosaic_path = profile_filename_path.replace(".jpg", "_mosaic.jpg") print "Creating mosaic at: " + profile_mosaic_path # TODO: parametrize and at least do 3 settings of mosaicify (tiles and zoom) # also probably paralellized creation of them with names corresponding to the quality osaic.mosaicify( target=profile_image, sources=images_with_path, tiles=128, zoom=8, output=profile_mosaic_path, ) return profile_mosaic_path
def createMosaic(filename, sources, target): osaic.mosaicify( target=target, sources=sources, tiles=128, zoom=4, output=filename, ) print "Success"
def make_mosaic(pics_urls, user): output_directory = os.path.join(settings.USERPICS_DIR, str(user.id)) if not os.path.exists(output_directory): os.makedirs(output_directory) downloader = DownloadManager(download_list=pics_urls, output_directory=output_directory) downloader.begin_downloads() pics_files = [os.path.join(output_directory, x) for x in os.listdir(output_directory)] output_filename = os.path.join(settings.MOSAICS_DIR, uuid.uuid1().hex + '.png') osaic.mosaicify( target=user.image.path, sources=pics_files, tiles=40, zoom=8, output=output_filename, ) mosaic = Mosaic(user=user) mosaic.image.name = output_filename[len(settings.MEDIA_ROOT) + 1:] mosaic.save()
""" 18/07/15 @author: Sammy Pfeiffer create_mosaic.py """ import osaic images = [ "r0sw3l_00.jpg", "r0sw3l_01.jpg", "r0sw3l_02.jpg", "r0sw3l_03.jpg", "r0sw3l_04.jpg", "r0sw3l_05.jpg", "r0sw3l_06.jpg", "r0sw3l_07.jpg", "r0sw3l_08.jpg", "r0sw3l_09.jpg", "r0sw3l_10.jpg", "r0sw3l_11.jpg", "r0sw3l_12.jpg", "r0sw3l_13.jpg", "r0sw3l_14.jpg" ] images_with_path = [] prev_path = "/home/sam/mosaic_ws/user_downloads/r0sw3l/" for img in images: images_with_path.append(prev_path + img) profile_image = "/home/sam/mosaic_ws/r0sw3l.jpg" osaic.mosaicify( target=profile_image, sources=images_with_path, tiles=128, zoom=8, output='/home/sam/mosaic_ws/mosaic_profile.png', )
18/07/15 @author: Sammy Pfeiffer create_mosaic.py """ import osaic images = ["r0sw3l_00.jpg", "r0sw3l_01.jpg", "r0sw3l_02.jpg", "r0sw3l_03.jpg", "r0sw3l_04.jpg", "r0sw3l_05.jpg", "r0sw3l_06.jpg", "r0sw3l_07.jpg", "r0sw3l_08.jpg", "r0sw3l_09.jpg", "r0sw3l_10.jpg", "r0sw3l_11.jpg", "r0sw3l_12.jpg", "r0sw3l_13.jpg", "r0sw3l_14.jpg"] images_with_path = [] prev_path = "/home/sam/mosaic_ws/user_downloads/r0sw3l/" for img in images: images_with_path.append(prev_path + img) profile_image = "/home/sam/mosaic_ws/r0sw3l.jpg" osaic.mosaicify( target=profile_image, sources=images_with_path, tiles=128, zoom=8, output='/home/sam/mosaic_ws/mosaic_profile.png', )