Skip to content

Thumbnails

There are many reasons why you might want to obtain a Thumbnail of (i) the complete document that you sent us, or (ii) parts of it.

Most useful are probably thumbnails of Sectionals. We will thus query the API to return a thumbnail for all sectionals detected in the supplied document. You can obtain thumbnails of the Page, Sheet and Canvas in an analogous manner.

Available Thumbnails

Page

When you submit a Drawing or Document to the WERK24 TechRead API, we look for the first Page that contains a Technical Drawing and use it as the main page. This is what you will receive when you request the W24AskPageThumbnail. It will be returned in gray-scale and exactly the way you submitted it (i.e, not rotated). Page Thumbnail

Requesting the Page Thumbnail

from werk24 import Hook, W24AskPageThumbnail
from werk24.models.techread import W24TechreadMessage
from werk24.utils import w24_read_sync

# define a function to read a file and return it as bytes
from . import get_drawing_bytes


def recv_thumbnail(message: W24TechreadMessage) -> None:
    """ Store the Thumbnail locally
    """
    if not message.is_successful:
        print("Exceptions occurred: {message.exceptions}")
        return

    with open("page_thumbnail.png", "wb+") as fid:
        fid.write(message.payload_bytes)


if __name__ == "__main__":

    # get your drawing bytes from a file or buffer
    drawing_bytes = get_drawing_bytes()

    # define what information you want to receive from the API
    # and what shall be done when the info is available.
    hooks = [Hook(ask=W24AskPageThumbnail(), function=recv_thumbnail)]

    # submit the request to the Werk24 API
    w24_read_sync(drawing_bytes, hooks)

Sheet

Sheet Thumbnail The Sheet thumbnail crops the Page to the region that actually belongs to the Technical Drawing. This will remove a lot of clutter (e.g., fax headers) and rotate the image to the proper reading direction.

Canvas

Canvas Thumbnail The Canvas thumbnail crops the Sheet to the regions that correspond to the Canvas(es). Be aware that some Sheets have multiple Canvases. They will be returned as separate images.

Remove Canvas Notes

If you want to perform a full neutralization of the Technical Drawing it can be helpful to remove all canvas notes. This can be done with the parameter remove_canvas_notes__dangerous. You can set this attribute following the below example.

Warning

We actively discourage the use of this parameter. Setting this parameter might remove information that is relevant for the production process. It is only helpful if the resulting thumbnail is always manually checked.

from werk24 import Hook, W24AskCanvasThumbnail
from werk24.models.techread import W24TechreadMessage
from werk24.utils import w24_read_sync

# define a function to read a file and return it as bytes
from . import get_drawing_bytes


def recv_thumbnail(message: W24TechreadMessage) -> None:
    """ Store the Thumbnail locally
    """
    if not message.is_successful:
        print("Exceptions occurred: {message.exceptions}")
        return

    with open("page_canvas.png", "wb+") as fid:
        fid.write(message.payload_bytes)


if __name__ == "__main__":

    # get your drawing bytes from a file or buffer
    drawing_bytes = get_drawing_bytes()

    # define what information you want to receive from the API
    # and what shall be done when the info is available.
    hooks = [Hook(
        ask=W24AskCanvasThumbnail(remove_canvas_notes__dangerous=True),
        function=recv_thumbnail)
    ]

    # submit the request to the Werk24 API
    w24_read_sync(drawing_bytes, hooks)

Sectional

Sectional Thumbnail Finally, you can request the Thumbnail of the individual Sectionals on each Canvas.