preserve cutoff line color in rotated preview
This commit is contained in:
@@ -159,8 +159,8 @@ def preview_deform_2d(image, angle_degrees):
|
||||
except Exception:
|
||||
return image
|
||||
|
||||
arr = np.asarray(image.convert("L")).astype(np.float32)
|
||||
h, w = arr.shape
|
||||
arr = np.asarray(image.convert("RGB")).astype(np.float32)
|
||||
h, w, _ = arr.shape
|
||||
yy, xx = np.mgrid[0:h, 0:w]
|
||||
|
||||
pivot_x = int(w * 0.55)
|
||||
@@ -183,7 +183,11 @@ def preview_deform_2d(image, angle_degrees):
|
||||
src_x = pivot_x + cos_t * dx + sin_t * dy
|
||||
src_y = pivot_y - sin_t * dx + cos_t * dy
|
||||
|
||||
warped = map_coordinates(arr, [src_y, src_x], order=1, mode="constant", cval=0)
|
||||
warped_channels = [
|
||||
map_coordinates(arr[..., channel], [src_y, src_x], order=1, mode="constant", cval=0)
|
||||
for channel in range(arr.shape[2])
|
||||
]
|
||||
warped = np.stack(warped_channels, axis=2)
|
||||
return Image.fromarray(np.clip(warped, 0, 255).astype(np.uint8)).convert("RGB")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user