Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram). AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan. Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
37 lines
992 B
TypeScript
37 lines
992 B
TypeScript
import * as ImageManipulator from 'expo-image-manipulator';
|
|
|
|
export const compressImage = async (
|
|
uri: string,
|
|
quality: number = 0.8
|
|
): Promise<string> => {
|
|
try {
|
|
const manipulatedImage = await ImageManipulator.manipulateAsync(
|
|
uri,
|
|
[{ resize: { width: 1080 } }], // Resize to max 1080px width
|
|
{ compress: quality, format: ImageManipulator.SaveFormat.JPEG }
|
|
);
|
|
return manipulatedImage.uri;
|
|
} catch (error) {
|
|
console.error('Image compression error:', error);
|
|
return uri; // Return original if compression fails
|
|
}
|
|
};
|
|
|
|
export const generateThumbnail = async (
|
|
uri: string,
|
|
width: number = 200
|
|
): Promise<string> => {
|
|
try {
|
|
const manipulatedImage = await ImageManipulator.manipulateAsync(
|
|
uri,
|
|
[{ resize: { width } }],
|
|
{ compress: 0.7, format: ImageManipulator.SaveFormat.JPEG }
|
|
);
|
|
return manipulatedImage.uri;
|
|
} catch (error) {
|
|
console.error('Thumbnail generation error:', error);
|
|
return uri;
|
|
}
|
|
};
|
|
|