viliusle / miniPaint

online image editor
http://viliusle.github.io/miniPaint/
Other
2.6k stars 606 forks source link

Constraining image dimensions #332

Closed BenjaminIrwin closed 1 year ago

BenjaminIrwin commented 1 year ago

Is there any way to constrain the dimensions of the base layer in minipaint?

I want to make it so that the underlying canvas is always square in aspect ratio. I want to be able to add non-square images but still make sure config.WIDTH== config.HEIGHT at all times. For example: https://ibb.co/xXRdTXP

If it can't be done easily can you point me to the right alterations in the code? Thanks so much

viliusle commented 1 year ago

Menu > image > Canvas size does it, related code: https://github.com/viliusle/miniPaint/blob/master/src/js/modules/image/size.js#L93

So you need to build your custom version and modify https://github.com/viliusle/miniPaint/blob/master/src/js/modules/file/open.js functions to keep square in aspect ratio. (search for "Autoresize_canvas_action")