imazen / imageflow

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow
https://docs.imageflow.io/
GNU Affero General Public License v3.0
4.14k stars 140 forks source link

Crop doesn't work in some cases #590

Closed FlipSs closed 1 year ago

FlipSs commented 3 years ago

Hello.

Seems like crop coordinate validation doesn't work right for some images, for some reason width and height got messed up. If I try to use Region with these coordinates everything works fine.

Coordinates: x1 = 0, x2 =1632, y1 = 2322, y2 =2850. Image (2322x4128): image

Error:

 Imageflow.Bindings.ImageflowException : ArgumentInvalid: InvalidNodeParams: Crop coordinates 0,1632 2322,2850 invalid for 4128x2322 bitmap at
    imageflow_core\src\flow\nodes\clone_crop_fill_expand.rs:403:25
    https://github.com/imazen/imageflow/blob/1f6dc67eef41132d5d3300676daa5d42ae7f8941/imageflow_core\src\flow\nodes\clone_crop_fill_expand.rs#L403
    imageflow_core\src\flow\nodes\clone_crop_fill_expand.rs:436:58
    https://github.com/imazen/imageflow/blob/1f6dc67eef41132d5d3300676daa5d42ae7f8941/imageflow_core\src\flow\nodes\clone_crop_fill_expand.rs#L436
    imageflow_core\src\flow\definitions.rs:302:54
    https://github.com/imazen/imageflow/blob/1f6dc67eef41132d5d3300676daa5d42ae7f8941/imageflow_core\src\flow\definitions.rs#L302
    imageflow_core\src\flow\execution_engine.rs:294:29
    https://github.com/imazen/imageflow/blob/1f6dc67eef41132d5d3300676daa5d42ae7f8941/imageflow_core\src\flow\execution_engine.rs#L294
    imageflow_core\src\context.rs:419:59
    https://github.com/imazen/imageflow/blob/1f6dc67eef41132d5d3300676daa5d42ae7f8941/imageflow_core\src\context.rs#L419
    imageflow_core\src\context_methods.rs:50:68
    https://github.com/imazen/imageflow/blob/1f6dc67eef41132d5d3300676daa5d42ae7f8941/imageflow_core\src\context_methods.rs#L50
lilith commented 2 years ago

This is likely due to rotation occurring, either as part of a instructed or optimized flip, or because the source image just uses metadata to rotate itself. Can you provide the exact code you're using to cause this so I can reproduce it later?