def decompress(images, delete_png=False, delete_json=False, folder=None):
if type(images) == str:<EOL><INDENT>return decompress([images])<EOL><DEDENT>filenames = copy(images) <EOL>decompressed_images = []<EOL>for orig_filename in filenames:<EOL><INDENT>debug('<STR_LIT>'.format(orig_filename))<EOL>try:<EOL><INDENT>filename, extension = os.path.splitext(orig_filename)<EOL>if folder:<EOL><INDENT>basename = os.path.basename(filename)<EOL>new_filename = os.path.join(folder, basename + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>new_filename = filename + '<STR_LIT>'<EOL><DEDENT>if os.path.isfile(new_filename):<EOL><INDENT>decompressed_images.append(new_filename)<EOL>msg = "<STR_LIT>""<STR_LIT>".format(orig_filename)<EOL>raise AssertionError(msg)<EOL><DEDENT>if extension != '<STR_LIT>':<EOL><INDENT>msg = "<STR_LIT>""<STR_LIT>".format(orig_filename)<EOL>raise AssertionError(msg)<EOL><DEDENT>img = Image.open(orig_filename)<EOL>img.load() <EOL>info = {}<EOL>with open(filename + '<STR_LIT>', '<STR_LIT:r>') as f:<EOL><INDENT>tags = json.load(f)<EOL>for tag,val in tags.items():<EOL><INDENT>if tag == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>if type(val) == list:<EOL><INDENT>val = tuple(val)<EOL><DEDENT>if type(val[<NUM_LIT:0>]) == list:<EOL><INDENT>val = tuple(tuple(x) for x in val)<EOL><DEDENT>info[int(tag)] = val<EOL><DEDENT><DEDENT>if '<STR_LIT>' in tags:<EOL><INDENT>img.putpalette(tags['<STR_LIT>'])<EOL><DEDENT>debug('<STR_LIT>'.format(new_filename))<EOL>img.save(new_filename, tiffinfo=info)<EOL>decompressed_images.append(new_filename)<EOL>if delete_png:<EOL><INDENT>os.remove(orig_filename)<EOL><DEDENT>if delete_json:<EOL><INDENT>os.remove(filename + '<STR_LIT>')<EOL><DEDENT><DEDENT>except (IOError, AssertionError) as e:<EOL><INDENT>print('<STR_LIT>'.format(e))<EOL><DEDENT><DEDENT>return decompressed_images<EOL>
Reverse compression from tif to png and save them in original format
    (ome.tif). TIFF-tags are gotten from json-files named the same as given
    images.


    Parameters
    ----------
    images : list of filenames
        Image to decompress.
    delete_png : bool
        Wheter to delete PNG images.
    delete_json : bool
        Wheter to delete TIFF-tags stored in json files on compress.

    Returns
    -------
    list of filenames
        List of decompressed files.