def _combine_images_in_group(
        self, image_elements: List[ImageElement]
    ) -> ImageElement:
        """Combine a list of ImageElements into a single ImageElement."""
        if not image_elements:
            raise ValueError("No images to combine.")

        images = []
        for node in image_elements:
            image_data = base64.b64decode(node.image)
            image = Image.open(io.BytesIO(image_data))
            # image = image.rotate(180)
            images.append(image)

        # Determine the width and total height of the final image
        width = max(img.width for img in images)
        total_height = sum(img.height for img in images)

        # Create a new blank image
        new_image = Image.new("RGB", (width, total_height))

        # Paste images one below the other
        y_offset = 0
        for img in images:
            new_image.paste(img, (0, y_offset))
            y_offset += img.height

        # Save or encode the final image
        buffered = io.BytesIO()
        new_image.save(buffered, format="PNG")
        final_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")

        return ImageElement(
            bbox=image_elements[0].bbox,
            image=final_base64,
            image_mimetype="image/png",
            text="",
        )
Combine a list of ImageElements into a single ImageElement.
src/openparse/processing/basic_transforms.py