#!/usr/bin/env python3

import shutil
from os import listdir
from os.path import isdir, exists

from wand.image import Image


BASE_PATH = '/mnt/dorota/geodotka/zdjecia'
TMP_CONVERTER_PATH = '/mnt/dorota/geodotka/zdjecia/tymczasowe_malumalu/'


def convert_main_photos():
    photos_dict = {}

    print('Kopiuję')
    for name in sorted(listdir(BASE_PATH)):
        path = f'{BASE_PATH}/{name}'
        if not isdir(path):
            continue

        maluszki_dir = f'{path}/maluszki'
        if exists(maluszki_dir):
            photo_paths = []
            for name_ in listdir(maluszki_dir):
                photo_path = f'{maluszki_dir}/{name_}'
                if not isdir(photo_path):
                    photo_paths.append(
                        photo_path.replace('maluszki', 'gotowe'))

        gotowe_dir = f'{path}/gotowe'
        if not exists(gotowe_dir):
            print(f'Alert, nie ma folderu gotowe w: {name}')
            continue

        photos_dict[name] = photo_paths

    for photo_path_list in photos_dict.values():
        for photo_path in photo_path_list:
            shutil.copy(photo_path, TMP_CONVERTER_PATH)

    print('Zmniejszam')
    for photo_name in sorted(listdir(TMP_CONVERTER_PATH)):
        img_path = f'{TMP_CONVERTER_PATH}{photo_name}'
        img_file = Image(filename=img_path)
        img_file.transform(resize='1200x900!')
        img_file.compression_quality = 55
        img_file.save(filename=img_path)


convert_main_photos()

c008e9ffc4b3e99c8b530687c66ab1a75e8aff2a
<mask token>


def convert_main_photos():
    photos_dict = {}
    print('Kopiuję')
    for name in sorted(listdir(BASE_PATH)):
        path = f'{BASE_PATH}/{name}'
        if not isdir(path):
            continue
        maluszki_dir = f'{path}/maluszki'
        if exists(maluszki_dir):
            photo_paths = []
            for name_ in listdir(maluszki_dir):
                photo_path = f'{maluszki_dir}/{name_}'
                if not isdir(photo_path):
                    photo_paths.append(photo_path.replace('maluszki', 'gotowe')
                        )
        gotowe_dir = f'{path}/gotowe'
        if not exists(gotowe_dir):
            print(f'Alert, nie ma folderu gotowe w: {name}')
            continue
        photos_dict[name] = photo_paths
    for photo_path_list in photos_dict.values():
        for photo_path in photo_path_list:
            shutil.copy(photo_path, TMP_CONVERTER_PATH)
    print('Zmniejszam')
    for photo_name in sorted(listdir(TMP_CONVERTER_PATH)):
        img_path = f'{TMP_CONVERTER_PATH}{photo_name}'
        img_file = Image(filename=img_path)
        img_file.transform(resize='1200x900!')
        img_file.compression_quality = 55
        img_file.save(filename=img_path)


<mask token>

<mask token>


def convert_main_photos():
    photos_dict = {}
    print('Kopiuję')
    for name in sorted(listdir(BASE_PATH)):
        path = f'{BASE_PATH}/{name}'
        if not isdir(path):
            continue
        maluszki_dir = f'{path}/maluszki'
        if exists(maluszki_dir):
            photo_paths = []
            for name_ in listdir(maluszki_dir):
                photo_path = f'{maluszki_dir}/{name_}'
                if not isdir(photo_path):
                    photo_paths.append(photo_path.replace('maluszki', 'gotowe')
                        )
        gotowe_dir = f'{path}/gotowe'
        if not exists(gotowe_dir):
            print(f'Alert, nie ma folderu gotowe w: {name}')
            continue
        photos_dict[name] = photo_paths
    for photo_path_list in photos_dict.values():
        for photo_path in photo_path_list:
            shutil.copy(photo_path, TMP_CONVERTER_PATH)
    print('Zmniejszam')
    for photo_name in sorted(listdir(TMP_CONVERTER_PATH)):
        img_path = f'{TMP_CONVERTER_PATH}{photo_name}'
        img_file = Image(filename=img_path)
        img_file.transform(resize='1200x900!')
        img_file.compression_quality = 55
        img_file.save(filename=img_path)


convert_main_photos()

<mask token>
BASE_PATH = '/mnt/dorota/geodotka/zdjecia'
TMP_CONVERTER_PATH = '/mnt/dorota/geodotka/zdjecia/tymczasowe_malumalu/'


def convert_main_photos():
    photos_dict = {}
    print('Kopiuję')
    for name in sorted(listdir(BASE_PATH)):
        path = f'{BASE_PATH}/{name}'
        if not isdir(path):
            continue
        maluszki_dir = f'{path}/maluszki'
        if exists(maluszki_dir):
            photo_paths = []
            for name_ in listdir(maluszki_dir):
                photo_path = f'{maluszki_dir}/{name_}'
                if not isdir(photo_path):
                    photo_paths.append(photo_path.replace('maluszki', 'gotowe')
                        )
        gotowe_dir = f'{path}/gotowe'
        if not exists(gotowe_dir):
            print(f'Alert, nie ma folderu gotowe w: {name}')
            continue
        photos_dict[name] = photo_paths
    for photo_path_list in photos_dict.values():
        for photo_path in photo_path_list:
            shutil.copy(photo_path, TMP_CONVERTER_PATH)
    print('Zmniejszam')
    for photo_name in sorted(listdir(TMP_CONVERTER_PATH)):
        img_path = f'{TMP_CONVERTER_PATH}{photo_name}'
        img_file = Image(filename=img_path)
        img_file.transform(resize='1200x900!')
        img_file.compression_quality = 55
        img_file.save(filename=img_path)


convert_main_photos()

import shutil
from os import listdir
from os.path import isdir, exists
from wand.image import Image
BASE_PATH = '/mnt/dorota/geodotka/zdjecia'
TMP_CONVERTER_PATH = '/mnt/dorota/geodotka/zdjecia/tymczasowe_malumalu/'


def convert_main_photos():
    photos_dict = {}
    print('Kopiuję')
    for name in sorted(listdir(BASE_PATH)):
        path = f'{BASE_PATH}/{name}'
        if not isdir(path):
            continue
        maluszki_dir = f'{path}/maluszki'
        if exists(maluszki_dir):
            photo_paths = []
            for name_ in listdir(maluszki_dir):
                photo_path = f'{maluszki_dir}/{name_}'
                if not isdir(photo_path):
                    photo_paths.append(photo_path.replace('maluszki', 'gotowe')
                        )
        gotowe_dir = f'{path}/gotowe'
        if not exists(gotowe_dir):
            print(f'Alert, nie ma folderu gotowe w: {name}')
            continue
        photos_dict[name] = photo_paths
    for photo_path_list in photos_dict.values():
        for photo_path in photo_path_list:
            shutil.copy(photo_path, TMP_CONVERTER_PATH)
    print('Zmniejszam')
    for photo_name in sorted(listdir(TMP_CONVERTER_PATH)):
        img_path = f'{TMP_CONVERTER_PATH}{photo_name}'
        img_file = Image(filename=img_path)
        img_file.transform(resize='1200x900!')
        img_file.compression_quality = 55
        img_file.save(filename=img_path)


convert_main_photos()

#!/usr/bin/env python3

import shutil
from os import listdir
from os.path import isdir, exists

from wand.image import Image


BASE_PATH = '/mnt/dorota/geodotka/zdjecia'
TMP_CONVERTER_PATH = '/mnt/dorota/geodotka/zdjecia/tymczasowe_malumalu/'


def convert_main_photos():
    photos_dict = {}

    print('Kopiuję')
    for name in sorted(listdir(BASE_PATH)):
        path = f'{BASE_PATH}/{name}'
        if not isdir(path):
            continue

        maluszki_dir = f'{path}/maluszki'
        if exists(maluszki_dir):
            photo_paths = []
            for name_ in listdir(maluszki_dir):
                photo_path = f'{maluszki_dir}/{name_}'
                if not isdir(photo_path):
                    photo_paths.append(
                        photo_path.replace('maluszki', 'gotowe'))

        gotowe_dir = f'{path}/gotowe'
        if not exists(gotowe_dir):
            print(f'Alert, nie ma folderu gotowe w: {name}')
            continue

        photos_dict[name] = photo_paths

    for photo_path_list in photos_dict.values():
        for photo_path in photo_path_list:
            shutil.copy(photo_path, TMP_CONVERTER_PATH)

    print('Zmniejszam')
    for photo_name in sorted(listdir(TMP_CONVERTER_PATH)):
        img_path = f'{TMP_CONVERTER_PATH}{photo_name}'
        img_file = Image(filename=img_path)
        img_file.transform(resize='1200x900!')
        img_file.compression_quality = 55
        img_file.save(filename=img_path)


convert_main_photos()
