docs: def remake_images_variants(profiles, clear=True):
      """
      Перестворює варіанти для картинок згідно налаштувань.
      profiles - список профілів, для картинок яких треба перестворити варіанти.
      clear - якщо True, тоді перед створенням варіантів будуть видалені ВСІ попередні варіанти.
      """
      assert isinstance(profiles, (list, tuple)) or profiles is None
      if profiles is None:
          profiles = dju_settings.DJU_IMG_UPLOAD_PROFILES.keys()
      profiles = set(('default',) + tuple(profiles))
      removed = remade = 0
      for profile in profiles:
          conf = get_profile_configs(profile=profile)
          root_path = os.path.join(settings.MEDIA_ROOT, dju_settings.DJU_IMG_UPLOAD_SUBDIR, conf['PATH'])
          if clear:
              for fn in get_files_recursive(root_path):
                  if dju_settings.DJU_IMG_UPLOAD_VARIANT_SUFFIX in os.path.basename(fn):
                      os.remove(fn)
                      removed += 1
          for fn in get_files_recursive(root_path):
              filename = os.path.basename(fn)
              if dju_settings.DJU_IMG_UPLOAD_VARIANT_SUFFIX in filename:
                  continue
              if dju_settings.DJU_IMG_UPLOAD_MAIN_SUFFIX not in filename:
                  continue
              img_id = '{profile}:{name}'.format(
                  profile=profile,
                  name=filename[:filename.find(dju_settings.DJU_IMG_UPLOAD_MAIN_SUFFIX)]
              )
              with open(fn, 'rb') as f:
                  for v_conf in conf['VARIANTS']:
                      label = v_conf['LABEL']
                      if not label:
                          label = get_variant_label(v_conf)
                      v_f = adjust_image(f, max_size=v_conf['MAX_SIZE'], new_format=v_conf['FORMAT'],
                                         jpeg_quality=v_conf['JPEG_QUALITY'], fill=v_conf['FILL'],
                                         stretch=v_conf['STRETCH'], return_new_image=True)
                      v_relative_path = get_relative_path_from_img_id(img_id, variant_label=label,
                                                                      ext=image_get_format(v_f))
                      v_full_path = media_path(v_relative_path)
                      save_file(v_f, v_full_path)
                      remade += 1
      return removed, remade