def METHOD_NAME(self, index, gallery, name):
    if len(gallery) == 0:
        return self.get_card_html(name), "There is no image in gallery to save as a preview."
    item = self.page.items.get(name, {})
    index = int(index)
    index = 0 if index < 0 else index
    index = len(gallery) - 1 if index >= len(gallery) else index
    img_info = gallery[index if index >= 0 else 0]
    image = generation_parameters_copypaste.image_from_url_text(img_info)
    geninfo, items = images.read_info_from_image(image)
    images.save_image_with_geninfo(image, geninfo, item["local_preview"])
    return self.get_card_html(name), ''