From 6bbd1e0c81af709a84dec7ae210d989d79593bcc Mon Sep 17 00:00:00 2001 From: Enis Gegic Date: Fri, 4 Oct 2024 09:28:12 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=20Mask=20Image=20Transfo?= =?UTF-8?q?rmation=20Issue=20(#10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ 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 --- .../ios/ReactNativeBackgroundRemover.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/react-native-background-remover/ios/ReactNativeBackgroundRemover.swift b/packages/react-native-background-remover/ios/ReactNativeBackgroundRemover.swift index 79005bf..b6ffed6 100644 --- a/packages/react-native-background-remover/ios/ReactNativeBackgroundRemover.swift +++ b/packages/react-native-background-remover/ios/ReactNativeBackgroundRemover.swift @@ -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])