WellNuo/utils/imageUtils.ts
Sergei d453126c89 feat: Room location picker + robster credentials
- Backend: Update Legacy API credentials to robster/rob2
- Frontend: ROOM_LOCATIONS with icons and legacyCode mapping
- Device Settings: Modal picker for room selection
- api.ts: Bidirectional conversion (code ↔ name)
- Various UI/UX improvements across screens

PRD-DEPLOYMENT.md completed (Score: 9/10)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-24 15:22:40 -08:00

54 lines
1.1 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,
}
);
return result.uri;
} catch (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) {
return uri;
}
}