Resize via TWIG does not work

Hello, I want to create a simple gallery, e.g.

<a href="{{ page.media[file.name].url }}" data-lightbox="gallery-item" title="{{page.title}}"> <img src="{{ page.media[file.name].url }}" alt=""></a>

The above srcipt is working.

But for better loading times, I want to cropResize the file in the tag.

Whenever I try to use page.media[file.name].resize(200,100).url or similar, I get an exception

An exception has been thrown during the rendering of a template ("Optimus-Error: Empty reply from server, Output: ").

How to solve this exception?