WellNuo Lite architecture: - Simplified navigation flow with NavigationController - Profile editing with API sync (/auth/profile endpoint) - OTP verification improvements - ESP WiFi provisioning setup (espProvisioning.ts) - E2E testing infrastructure (Playwright) - Speech recognition hooks (web/native) - Backend auth enhancements This is the stable version submitted to App Store. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import * as ImageManipulator from 'expo-image-manipulator';
|
|
|
|
/**
|
|
* Optimize image for avatar upload
|
|
* - Resize to max 400x400
|
|
* - Compress to JPEG with 80% quality
|
|
* - Returns optimized URI
|
|
*/
|
|
export async function optimizeAvatarImage(uri: string): Promise<string> {
|
|
try {
|
|
const result = await ImageManipulator.manipulateAsync(
|
|
uri,
|
|
[
|
|
{ resize: { width: 400, height: 400 } },
|
|
],
|
|
{
|
|
compress: 0.8,
|
|
format: ImageManipulator.SaveFormat.JPEG,
|
|
}
|
|
);
|
|
|
|
console.log('[ImageUtils] Optimized avatar:', {
|
|
original: uri.substring(0, 50),
|
|
optimized: result.uri.substring(0, 50),
|
|
width: result.width,
|
|
height: result.height,
|
|
});
|
|
|
|
return result.uri;
|
|
} catch (error) {
|
|
console.error('[ImageUtils] Failed to optimize image:', error);
|
|
// Return original if optimization fails
|
|
return uri;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Optimize image for general upload with custom size
|
|
*/
|
|
export async function optimizeImage(
|
|
uri: string,
|
|
maxSize: number = 800,
|
|
quality: number = 0.8
|
|
): Promise<string> {
|
|
try {
|
|
const result = await ImageManipulator.manipulateAsync(
|
|
uri,
|
|
[
|
|
{ resize: { width: maxSize, height: maxSize } },
|
|
],
|
|
{
|
|
compress: quality,
|
|
format: ImageManipulator.SaveFormat.JPEG,
|
|
}
|
|
);
|
|
|
|
return result.uri;
|
|
} catch (error) {
|
|
console.error('[ImageUtils] Failed to optimize image:', error);
|
|
return uri;
|
|
}
|
|
}
|