Skip to content

Commit

Permalink
fix: πŸ› Mask Image Transformation Issue (#10)
Browse files Browse the repository at this point in the history
* ✨ Improve error handling
-Added check to avoid producing images with large size
-Use CIContext for proper image conversion process to avoid crashes on some devices

* πŸ› Fix mask image transformation issue

* πŸ› Fix mask image transformation issue
  • Loading branch information
enisit authored Oct 4, 2024
1 parent c760364 commit 6bbd1e0
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public class BackgroundRemoverSwift: NSObject {
let scaleX = originalImage.extent.width / maskImage.extent.width
let scaleY = originalImage.extent.height / maskImage.extent.height

// Avoid up-scaling if mask dimensions are too small
if scaleX > 1 || scaleY > 1 {
maskImage = maskImage.transformed(by: CGAffineTransform(scaleX: scaleX, y: scaleY))
}
maskImage = maskImage.transformed(by: CGAffineTransform(scaleX: scaleX, y: scaleY))

let maskedImage = originalImage.applyingFilter("CIBlendWithMask", parameters: [kCIInputMaskImageKey: maskImage])

Expand Down

0 comments on commit 6bbd1e0

Please sign in to comment.