Skip to content

SNO7E-G/Color-Palette-Extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Color Palette Extractor

License: MIT React Vite Tailwind CSS

A modern web application built with React and Vite that allows users to effortlessly extract color palettes from images. Upload an image via drag & drop, file selection, or pasting, and instantly get a visually appealing palette of dominant colors.

πŸ“š Table of Contents

✨ Features

  • Multiple Upload Methods: Offers flexibility for users to provide images:
    • πŸ–±οΈ Drag and Drop: Intuitively drop image files directly onto the upload zone.
    • πŸ“‹ Paste from Clipboard: Conveniently paste images copied from other applications.
    • πŸ“ File Selection: Use the standard file browser to select local image files.
  • Efficient Color Extraction: Utilizes the powerful colorthief library to quickly analyze the uploaded image and extract the 8 most prominent colors, forming the palette.
  • Interactive Palette Display: Presents the generated palette in an engaging and usable format:
    • Displays colors in a responsive grid layout.
    • πŸ–±οΈ One-Click Copy: Instantly copy a color's HEX code to the clipboard by clicking its swatch.
    • πŸ‘€ Hover Effect: Reveals the HEX code clearly when hovering over a color.
    • ⌨️ Keyboard Navigation: Fully accessible via keyboard (arrow keys to navigate, Enter/Space to copy).
    • 🎨 Smart Text Contrast: Automatically calculates and applies black or white text for HEX codes, ensuring readability against any background color.
  • Versatile Export Options: Allows users to save their palettes for later use:
    • JSON: Export the palette data (array of hex codes, timestamp) in a structured JSON format, ideal for integration into other tools or codebases.
    • PNG: Export a high-resolution PNG image capture of the visual color palette display using html2canvas, perfect for presentations, documentation, or sharing.
  • User-Friendly Interface: Designed for ease of use and clarity:
    • πŸ–ΌοΈ Image Preview: Shows a thumbnail of the uploaded image before processing.
    • ⏳ Visual Feedback: Incorporates loading spinners, progress indicators, and success/error messages during processing and export operations.
    • ❌ Robust Error Handling: Provides clear feedback for common issues like invalid file types (supports JPG/PNG), exceeding size limits (max 5MB), or color extraction problems.
    • πŸ“± Responsive Design: Adapts seamlessly to various screen sizes, offering a consistent experience on desktops, tablets, and mobile devices.
  • Modern Tech Stack: Leverages current web technologies for optimal performance and developer experience:
    • Built with React for component-based UI development.
    • Powered by Vite for lightning-fast HMR (Hot Module Replacement) and optimized builds.
    • Styled with Tailwind CSS for rapid, utility-first styling.

πŸ“‚ Project Structure

color-palette-extractor/
β”œβ”€β”€ public/             # Static assets (e.g., favicon)
β”œβ”€β”€ src/                # Source code
β”‚   β”œβ”€β”€ assets/         # Project assets (if any, e.g., images used in UI)
β”‚   β”œβ”€β”€ components/     # Reusable React components
β”‚   β”‚   β”œβ”€β”€ ExportButtons.jsx
β”‚   β”‚   β”œβ”€β”€ PaletteViewer.jsx
β”‚   β”‚   └── UploadArea.jsx
β”‚   β”œβ”€β”€ App.css         # Main application styles
β”‚   β”œβ”€β”€ App.jsx         # Root application component
β”‚   β”œβ”€β”€ index.css       # Global styles and Tailwind directives
β”‚   └── main.jsx        # Application entry point
β”œβ”€β”€ .eslintrc.cjs       # ESLint configuration
β”œβ”€β”€ .gitignore          # Git ignore rules
β”œβ”€β”€ index.html          # Main HTML template for Vite
β”œβ”€β”€ LICENSE             # Project license file (MIT)
β”œβ”€β”€ package-lock.json   # Exact dependency versions
β”œβ”€β”€ package.json        # Project metadata and dependencies
β”œβ”€β”€ postcss.config.js   # PostCSS configuration (for Tailwind)
β”œβ”€β”€ README.md           # This file
β”œβ”€β”€ tailwind.config.js  # Tailwind CSS configuration
└── vite.config.js      # Vite configuration

πŸ› οΈ Tech Stack

  • Frontend Framework: React - For building the user interface components.
  • Build Tool: Vite - Provides a fast development server and optimized build process.
  • Styling: Tailwind CSS - A utility-first CSS framework for rapid UI development.
  • Color Extraction: ColorThief - A JavaScript library for extracting dominant colors from images.
  • File Saving: FileSaver.js - For saving generated files (JSON, PNG) on the client-side.
  • Image Generation: html2canvas - For capturing the palette display as an image.

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository:
    git clone <your-repository-url>
    cd color-palette-extractor
  2. Install dependencies:
    npm install
    # or
    # yarn install
    For production environments, consider using:
    npm ci

Running the Development Server

  1. Start the Vite development server:
    npm run dev
    # or
    # yarn dev
  2. Open your browser and navigate to http://localhost:5173 (or the port specified in the console).

Building for Production

  1. Create an optimized production build:

    npm run build
    # or
    # yarn build

    The production files will be located in the dist directory.

  2. Preview the production build locally:

    npm run preview
    # or
    # yarn preview

πŸ“– Usage

  1. Launch the application.
  2. Use one of the available methods (drag & drop, paste, click to upload) to provide an image (JPG or PNG, up to 5MB).
  3. Wait for the application to process the image and display the extracted 8-color palette.
  4. Interact with the palette:
    • Hover over colors to view their HEX codes.
    • Click a color to copy its HEX code.
    • Use arrow keys to navigate and Enter/Space to copy.
  5. Use the "Export as JSON" or "Export as PNG" buttons to save the palette.

🀝 Contributing

Contributions are welcome! If you have suggestions for improvements or find any issues, please feel free to open an issue or submit a pull request.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Mahmoud Ashraf (SNO7E)

πŸ™ Acknowledgements

This project utilizes the following open-source software:

We are grateful to the developers and communities behind these projects.

About

A modern web application built with React and Vite that allows users to effortlessly extract color palettes from images. Upload an image via drag & drop, file selection, or pasting, and instantly get a visually appealing palette of dominant colors.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors