diff --git a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt --- a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt +++ b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/thumbhash/ThumbhashModule.kt @@ -53,7 +53,7 @@ val rgba = bitmap.toRGBA() val thumbHash = ThumbHash.rgbaToThumbHash(bitmap.width, bitmap.height, rgba) - return Base64.encodeToString(thumbHash, Base64.DEFAULT) + return Base64.encodeToString(thumbHash, Base64.NO_WRAP) } // endregion diff --git a/native/utils/thumbhash-module.js b/native/utils/thumbhash-module.js --- a/native/utils/thumbhash-module.js +++ b/native/utils/thumbhash-module.js @@ -7,12 +7,18 @@ +generateThumbHash: (photoURI: string) => Promise, } = requireNativeModule('Thumbhash'); +const newLineRegex = /\n/g; async function generateThumbHash(photoURI: string): Promise { invariant( platformUtilsModule.generateThumbHash, 'generateThumbHash() unavailable. Check if Thumbhash expo-module is autolinked', ); - return await platformUtilsModule.generateThumbHash(photoURI); + + const rawThumbHash = await platformUtilsModule.generateThumbHash(photoURI); + + // Sometimes native base64 modules encode the string with newlines, + // which breaks the thumbhash format + return rawThumbHash.replace(newLineRegex, ''); } export { generateThumbHash };