If you upload images via Finder or via image field in a collection, the files are - just files somewhere on your server. Use assets instead to have database entries for each image and than you can query them via image id or image path.
See this thread for some more info about the differences between images and assets: "Select Image" results in "Something went wrong" on asset field
<img src="/api/cockpit/image?token=xxtokenxx&src=path&w=200&h=200&f[brighten]=25&o=true" />
Without o=true
you receive a relative url to the generated thumbnail. With enabled output, you receive the whole image.
I’m not sure, but I think I had some problems querying assets with relative urls when a part of the subdirectory is missing… If so, use the image id instead &src=image_id
.