Browse Source

Match Go crop params: default x1/y1 to 0 when not provided

rust-volume-server
Chris Lu 3 days ago
parent
commit
d2681c5e07
  1. 12
      seaweed-volume/src/server/handlers.rs

12
seaweed-volume/src/server/handlers.rs

@ -1753,8 +1753,16 @@ fn maybe_resize_image(data: &[u8], ext: &str, query: &ReadQueryParams) -> Vec<u8
}
fn maybe_crop_image(data: &[u8], ext: &str, query: &ReadQueryParams) -> Vec<u8> {
let (x1, y1, x2, y2) = match (query.crop_x1, query.crop_y1, query.crop_x2, query.crop_y2) {
(Some(x1), Some(y1), Some(x2), Some(y2)) if x2 > x1 && y2 > y1 => (x1, y1, x2, y2),
let (x1, y1, x2, y2) = match (query.crop_x2, query.crop_y2) {
(Some(x2), Some(y2)) => {
let x1 = query.crop_x1.unwrap_or(0);
let y1 = query.crop_y1.unwrap_or(0);
if x2 > x1 && y2 > y1 {
(x1, y1, x2, y2)
} else {
return data.to_vec();
}
}
_ => return data.to_vec(),
};

Loading…
Cancel
Save