Transform your digital images into beautiful artistic sketches with just one click!
DoodlePic is a modern web application that converts your photos into stunning pencil sketches using advanced computer vision algorithms. Built with Flask and OpenCV, it provides a seamless, responsive experience across all devices.
๐ฌ Watch Demo Video
- ๐ผ๏ธ Instant Image-to-Sketch Conversion - Transform any image into artistic pencil sketch
- ๐ฑ Fully Responsive Design - Works seamlessly on all devices
- โก Real-time Processing - Fast image processing with optimized algorithms
- ๐๏ธ Smart File Management - Automatic cleanup prevents storage accumulation
- ๐พ One-Click Download - Download sketches in high quality PNG format
- ๐ฏ File Validation - Supports PNG, JPG, JPEG, GIF formats (5MB limit)
- ๐ก๏ธ Error Handling - Robust error handling for smooth user experience
graph TB
A[User Visits Homepage] --> B[Upload Image]
B --> C{File Validation}
C -->|Valid| D[Image Processing]
C -->|Invalid| E[Error Message]
D --> F[Sketch Generation]
F --> G[Display Result]
G --> H[Download Sketch]
G --> I[Create New Sketch]
I --> A
H --> J[File Cleanup]
graph TB
subgraph "Frontend Layer"
A[HTML Templates]
B[CSS Styling]
C[JavaScript]
end
subgraph "Backend Layer"
D[Flask Application]
E[Route Handlers]
F[File Management]
end
subgraph "Processing Layer"
G[OpenCV Engine]
H[Image Processing]
I[Pygame Renderer]
end
subgraph "Storage Layer"
J[Upload Directory]
K[Output Directory]
L[Static Assets]
end
A --> D
B --> D
C --> D
D --> E
E --> F
E --> G
G --> H
H --> I
F --> J
F --> K
D --> L
sequenceDiagram
participant U as User
participant F as Frontend
participant B as Backend
participant P as Processing
participant S as Storage
U->>F: Upload Image
F->>B: POST /upload
B->>B: Validate File
B->>S: Save Upload
B->>P: Process Image
P->>P: Apply Sketch Algorithm
P->>S: Save Sketch
B->>S: Cleanup Upload
B->>F: Redirect to Output
F->>U: Display Sketch
U->>F: Download Request
F->>B: GET /static/output/sketch.png
B->>S: Retrieve File
S->>B: Return File
B->>F: Serve File
F->>U: Download Sketch
- Python 3.8+ - Download Python
- Git - Download Git
-
Clone the Repository
git clone https://github.com/yourusername/DoodlePic-project.git cd DoodlePic-project -
Create Virtual Environment (Recommended)
# Windows python -m venv venv venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Run the Application
python app.py
-
Access the Application
- Open your browser:
http://localhost:5000 - Start converting your images!
- Open your browser:
- Upload Image: Click upload area or drag & drop (PNG, JPG, JPEG, GIF - max 5MB)
- Processing: Application automatically processes your image (2-5 seconds)
- Download: View generated sketch and click "Download Sketch" to save
| Format | Extension | Max Size | Notes |
|---|---|---|---|
| PNG | .png | 5MB | Recommended |
| JPEG | .jpg, .jpeg | 5MB | Most common |
| GIF | .gif | 5MB | First frame only |
GET /- Homepage with upload interfacePOST /upload- Upload and process imageGET /output/<filename>- Display processed sketchGET /static/output/<filename>- Serve sketch filePOST /cleanup- Manual file cleanup
Backend: Flask 3.0.3, OpenCV 4.10.0, NumPy 1.26.4, Pygame 2.5.2
Frontend: HTML5, CSS3, Vanilla JavaScript
Processing: Computer Vision algorithms with OpenCV
The sketch generation uses a sophisticated computer vision algorithm:
flowchart TD
A[Original Image] --> B[Convert to Grayscale]
B --> C[Invert Grayscale]
C --> D[Apply Gaussian Blur]
D --> E[Invert Blurred Image]
E --> F[Blend with Original]
F --> G[Generate Sketch]
G --> H[Render with Pygame]
H --> I[Save as PNG]
-
Grayscale Conversion
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
-
Image Inversion
inverted_gray = 255 - gray_image
-
Gaussian Blur Application
blurred = cv2.GaussianBlur(inverted_gray, (21, 21), 0)
-
Blend Operation
sketch = cv2.divide(gray_image, 255 - blurred, scale=256.0)
- Memory Management: Automatic cleanup of temporary files
- Processing Speed: Optimized OpenCV operations
- File Handling: Efficient I/O operations
- Background Tasks: Periodic cleanup threading
| Image Size | Processing Time | Memory Usage |
|---|---|---|
| 1MP (1024x768) | ~2 seconds | ~50MB |
| 2MP (1920x1080) | ~3 seconds | ~80MB |
| 5MP (2560x1920) | ~5 seconds | ~150MB |
- Minimum: 2GB RAM, 1GB storage
- Recommended: 4GB RAM, 2GB storage
- CPU: Any modern processor (2+ cores recommended)
We welcome contributions! Here's how you can help:
- Fork the Repository
- Create Feature Branch
git checkout -b feature/amazing-feature
- Make Changes
- Run Tests
python -m pytest tests/
- Commit Changes
git commit -m "Add amazing feature" - Push to Branch
git push origin feature/amazing-feature
- Open Pull Request
- Code Style: Follow PEP 8 guidelines
- Documentation: Update README for new features
- Testing: Add tests for new functionality
- Performance: Consider performance implications
- ๐จ UI/UX Improvements
- ๐ฑ Mobile Optimization
- ๐ Performance Enhancements
- ๐งช Additional Image Effects
- ๐ง Code Optimization
- ๐ Documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- โ Commercial use
- โ Modification
- โ Distribution
- โ Private use
- โ Liability
- โ Warranty
- ๐ง Email: [email protected]
- ๐ Issues: GitHub Issues
-
Import Error: No module named 'cv2'
pip install opencv-python
-
Permission Denied Error
# Windows Run as Administrator # macOS/Linux sudo pip install -r requirements.txt
-
Port Already in Use
# Kill process on port 5000 lsof -ti:5000 | xargs kill -9
- Windows: Ensure Visual C++ redistributables are installed
- macOS: May require Xcode command line tools
- Linux: Install python3-dev and build-essential
Special thanks to:
- OpenCV Community - For the amazing computer vision library
- Flask Team - For the lightweight and powerful web framework
- Pygame Developers - For the graphics rendering capabilities
- Contributors - Everyone who has contributed to this project
- v1.0.0 - Initial release with basic sketch functionality
- v1.1.0 - Added file cleanup and responsive design
- v1.2.0 - Performance optimizations and error handling
Made with โค๏ธ by Melwyn Titus