venveo/serverless-sharp

Allow a max width and height for output images

mattgrayisok opened this issue · 2 comments

It seems as though MAX_IMAGE_WIDTH/HEIGHT apply defaults for when a specific width or height are not provided.

When a specific width or height are requested these config settings are ignored. This allows users to request images 9999999999px wide if they feel the desire (and can generate signed urls)

(I spent a while misunderstanding this and thought that they were global output constraints and got very confused when my output images were larger than the MAX settings. It might be worth at least renaming them)

It would be useful to have some additional env vars which constrain the global maximum width and height of output images to prevent this.

Were you able to actually reproduce this? Unless I'm mistaken, the width/height constraints should have been ultimately enforced by the schema, per: https://github.com/venveo/serverless-sharp/blob/master/data/schema.json#L2766-L2791

Thanks for the pointer - I was running in a custom setup without the schema being applied to the inputs and it was therefore not being constrained.

I've added a similar solution to my setup and it's now working as expected. Thanks!