A Vue.js application that generates photo mosaics by combining a target image with a pool of smaller images. Built with Nuxt 3 and Tailwind CSS, this application processes images client-side using Web Workers for optimal performance. This project was created by v0, an advanced AI coding assistant.
- Upload a target photo to be transformed into a mosaic
- Add multiple photos to create a pool of images for the mosaic
- Delete individual photos from the pool
- Adjust tile size for the mosaic
- Adjust color balance between the original image and the mosaic tiles
- Cancel mosaic generation at any time
- Progress tracking during mosaic generation
- Dark mode toggle
- Responsive design that works on both desktop and mobile devices
- Download generated mosaic
- Collapsible "Important Information" section
- Tooltips for Tile Size and Color Adjustment parameters
- Added a collapsible "Important Information" section using Headless UI components
- Implemented tooltips for Tile Size and Color Adjustment sliders
- Updated ChevronUpIcon import to use "@heroicons/vue/24/solid"
- Enhanced mosaic generation process in the Web Worker
- Improved error handling in the Web Worker
- Fixed issues with chunk processing in the Web Worker
- Tile Size: Determines the size of each mosaic tile. Smaller values create more detailed mosaics but take longer to generate.
- Color Adjustment: Controls the balance between the original image colors and the mosaic tile colors. Higher values result in a mosaic that's closer to the original image colors.
Before you begin, ensure you have the following installed:
- Node.js (version 14.x or later)
- npm or yarn
- Git
-
Clone the repository
git clone <repository-url> cd mosaic-generator
-
Install dependencies
# Using npm npm install # Using yarn yarn install
-
Start the development server
# Using npm npm run dev # Using yarn yarn dev
-
Open your browser
Navigate to
http://localhost:3000
to see the application running.
mosaic-generator/
├── pages/
│ └── index.vue # Main application component
├── public/
│ └── mosaic-worker.js # Web Worker for image processing
├── nuxt.config.ts # Nuxt configuration
└── package.json # Project dependencies
-
Image Upload
- The target photo is uploaded and displayed
- Pool photos can be added multiple times and deleted individually
-
Mosaic Generation
-
The application divides the target image into small tiles
-
For each tile, it:
- Calculates the average color
- Finds the best matching image from the pool
- Replaces the tile with the matching image
-
-
Performance Optimization
- Uses Web Workers for heavy computation
- Implements chunked data transfer to handle large images
- Provides progress updates during generation
- Web Worker: Handles image processing in a separate thread to keep the UI responsive
- Chunked Data Transfer: Splits large images into 5MB chunks for efficient transfer
- Canvas API: Used for image manipulation and color analysis
- Vue 3 Composition API: Manages application state and UI updates
- Headless UI: Implements collapsible sections and tooltips
-
Upload Target Photo
- Click on the "Select target photo" input to choose your main image
-
Add Pool Photos
- Use the "Upload pool photos" input to select multiple images for your mosaic tiles
- You can add more photos at any time
-
Manage Pool Photos
- Delete unwanted photos from the pool by clicking the "×" button on each image
-
Adjust Mosaic Parameters
- Use the "Tile Size" slider to set the size of mosaic tiles
- Use the "Color Adjustment" slider to balance between original and mosaic colors
-
Generate Mosaic
- Click the "Generate Mosaic" button to start the process
- A progress indicator will show the current status and elapsed time
-
Cancel Generation
- If needed, click the "Cancel Generation" button to stop the process
-
View Result
- Once complete, the generated mosaic will appear in the "Result" section
-
Download Mosaic
- Click the "Download Mosaic" button to save the generated image
-
Toggle Dark Mode
- Use the dark mode toggle in the top right corner to switch between light and dark modes
- Modify
pages/index.vue
for UI changes - Update
public/mosaic-worker.js
for image processing logic - Test thoroughly with various image sizes and quantities
```bash
# Using npm
npm run build
npm run start
# Using yarn
yarn build
yarn start
```
If you encounter any issues with mosaic generation:
-
Check the browser console for error messages or logs
-
Image Upload Issues
- Ensure images are in supported formats (PNG, JPEG)
- Check file size limits in your browser
-
Generation Performance
- Try using smaller tile sizes or fewer pool photos if the generation is taking too long
- Use smaller target images for quicker results
-
Browser Compatibility
- Ensure your browser supports Web Workers and modern JavaScript features
- Try updating your browser to the latest version
-
Clear browser cache and reload
-
Check for updates
- Make sure you're using the latest version of the application
If the issue persists, please report it by opening an issue on the project repository with a detailed description of the problem and steps to reproduce it.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses various open-source libraries and tools. We thank the community for their contributions.
This project was created by v0, an advanced AI coding assistant developed by Vercel. v0 is designed to assist developers in creating efficient, modern web applications.
Made with ❤️ by the Mosaic Photo Generator Team