◉RORK LABJP
●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens
Articles/Dev Tools
⬡ Dev Tools/2026-03-14Intermediate

Rork Max Camera & Gallery Guide — Implementing Photo Capture and Image Selection

Complete guide to implementing camera access and gallery features in Rork Max apps. From native API integration to image optimization.

rork-max40cameragallerynative-apiimage-handling

Camera & Gallery Features in Rork Max

Photography and image selection capabilities have become essential for modern mobile applications. A social app, an e-commerce platform, a document scanner — each one lives or dies on how smoothly a user can pull in a photo, so camera and gallery integration sits right on the line of engagement and satisfaction.

Getting Started with Camera Integration

Understanding Permission Requirements

Before accessing the device camera, you must request the appropriate permissions. On iOS, these are declared in Info.plist, while on Android, they're specified in AndroidManifest.xml. Rork Max simplifies this process with built-in permission handling.

import { Camera } from 'react-native-vision-camera';
import { useState } from 'react';
 
export function CameraScreen() {
  const [hasPermission, setHasPermission] = useState(false);
 
  // Request camera access from user
  const requestCameraPermission = async () => {
    try {
      const status = await Camera.requestCameraPermission();
      setHasPermission(status === 'granted');
      console.log(`Camera permission status: ${status}`);
      // Expected output: Camera permission status: granted
    } catch (error) {
      console.error('Permission request failed:', error);
    }
  };
 
  return (
    <div>
      <button onClick={requestCameraPermission}>
        Enable Camera
      </button>
      {hasPermission && <p>Camera is ready to use</p>}
    </div>
  );
}

This code handles the permission request lifecycle gracefully, providing user feedback while maintaining clear state management.

Implementing Image Selection

Building a Gallery Picker

The image picker functionality allows users to select photos from their device library. Rork Max integrates seamlessly with platform-specific image picker libraries.

import ImagePicker from 'react-native-image-picker';
import { useState } from 'react';
 
export function GallerySelector() {
  const [selectedImage, setSelectedImage] = useState(null);
 
  const pickImage = async () => {
    const options = {
      mediaType: 'photo',
      quality: 0.8,
      maxWidth: 1920,
      maxHeight: 1440,
    };
 
    ImagePicker.launchImageLibrary(options, (response) => {
      if (response.didCancel) {
        console.log('User cancelled image selection');
      } else if (response.error) {
        console.error('Gallery error:', response.error);
      } else {
        setSelectedImage(response.assets[0]);
        console.log(`Selected image: ${response.assets[0].fileName}`);
        // Expected output: Selected image: photo_2026_03_14.jpg
      }
    });
  };
 
  return (
    <div>
      <button onClick={pickImage}>Choose from Gallery</button>
      {selectedImage && (
        <img
          src={selectedImage.uri}
          alt="Selected"
          style={{ maxWidth: '300px' }}
        />
      )}
    </div>
  );
}

The configuration options allow you to control quality, maximum dimensions, and media type, ensuring consistency across different devices.

Image Processing and Optimization

Resizing and Compression

High-resolution images directly from the camera consume significant bandwidth and storage. Implementing image optimization is critical for app performance and user experience.

import ImageResizer from 'react-native-image-resizer';
 
export async function optimizeImage(imagePath) {
  try {
    const resizedImage = await ImageResizer.createResizedImage(
      imagePath,
      1200,  // width
      900,   // height
      'JPEG',
      85,    // quality (1-100)
      0      // rotation
    );
 
    console.log(`Image optimized: ${resizedImage.size} bytes`);
    // Expected output: Image optimized: 245000 bytes
    return resizedImage;
  } catch (error) {
    console.error('Image optimization failed:', error);
  }
}

This approach typically reduces file size by 50-70% while maintaining acceptable visual quality for most use cases.

Enhancing User Experience

Progress Tracking and Error Handling

When uploading images, especially larger files, showing progress updates keeps users informed and improves perceived performance.

export function ImageUploadWithProgress() {
  const [progress, setProgress] = useState(0);
  const [isUploading, setIsUploading] = useState(false);
 
  const uploadImage = async (imagePath) => {
    setIsUploading(true);
    const xhr = new XMLHttpRequest();
 
    xhr.upload.addEventListener('progress', (e) => {
      if (e.lengthComputable) {
        const percentComplete = (e.loaded / e.total) * 100;
        setProgress(percentComplete);
        console.log(`Upload progress: ${Math.round(percentComplete)}%`);
      }
    });
 
    xhr.addEventListener('load', () => {
      setIsUploading(false);
      console.log('Upload completed successfully');
      // Expected output: Upload completed successfully
    });
 
    // Upload execution (abbreviated)
  };
 
  return (
    <div>
      {isUploading && <p>Progress: {Math.round(progress)}%</p>}
    </div>
  );
}

Performance Best Practices

Memory Management Strategies

Camera operations are memory-intensive. Implementing these practices prevents crashes and ensures smooth operation:

  • Image Caching: Avoid redundant reloading of the same images
  • Proper Cleanup: Release resources when components unmount
  • Background Processing: Offload heavy image operations to worker threads

For more on native performance optimization, see the Rork Max Native API Guide.

Integration with Other Features

User profile images often integrate with authentication systems. Learn more in the Rork Max Social Login Implementation Guide.

For adding polish to your image UI with animations, check out the Rork Max Animations Guide.

Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⬡ Dev Tools2026-11-19
New Wallpapers Showed Up Everywhere Except the Filters: Ship the Count and the Category Lists Together
I added 67 wallpapers in one batch. They appeared in the full list and in New, but not under a single category filter, because I had raised the ID limit and forgotten to ship the category lists. Here is a pre-bump check, a client-side way to spot silent fallbacks in an Expo app, and a post-release count against the origin.
⬡ Dev Tools2026-11-11
On Android, expo/fetch can return a cut-off response as a success — why I read the body as a stream
If the connection drops mid-response, Android's expo/fetch can still resolve text() with the partial string. Here is why it looks like a JSON SyntaxError, and a short stream-reading helper.
⬡ Dev Tools2026-11-04
Catching the Few Seconds Before Streaming Audio Starts: A Loading State and a Timeout
You tap play and nothing happens for a moment. Here is how I model that gap with expo-audio: a requested flag, a 400ms delayed spinner, and an 8-second timeout.