This project is a web application that allows users to extract color schemes from websites. The frontend is built with Angular, and the backend is a Spring Boot API.
- Extracts colors from website HTML (inline styles), CSS (linked stylesheets), and images.
- Identifies dominant colors from images.
- Counts color frequencies and returns the top N (currently 20) most frequent colors.
- Provides HEX, RGB, and friendly names for extracted colors (using a standard list of 140 web colors).
- Simple web UI to input a URL and view the extracted color palette.
The project is organized into two main parts:
- The root directory contains the Java Spring Boot backend application.
color-extractor-ui/: The Angular frontend application.
- Java JDK (version 11 or higher, as specified in
pom.xml) - Maven (for building the backend)
- Node.js and npm (for building and running the frontend, Node v18+ used in development)
- Angular CLI (version 17 used,
npm install -g @angular/cli@17)
- Navigate to the project root directory (this is where
pom.xmlis located). - Build the project using Maven:
./mvnw clean package # or `mvn clean package` if you have Maven installed globally - Run the application:
The backend API will start on
java -jar target/colorschemeidentifier-0.0.1-SNAPSHOT.jar
http://localhost:8080.
- Navigate to the frontend directory:
cd color-extractor-ui - Install dependencies (if you haven't already):
npm install
- Run the Angular development server:
The frontend application will be available at
ng serve
http://localhost:4200.
- Open your browser and go to
http://localhost:4200. - Enter a full website URL (including
http://orhttps://) into the input field. - Click "Extract Colors".
- The application will display the top extracted colors from the website.
The backend exposes the following endpoint:
- GET
/api/colors- Query Parameter:
url(String, required) - The URL of the website to analyze. - Success Response (200 OK): Returns a JSON array of
ColorInfoobjects, sorted by frequency.[ { "hexValue": "#RRGGBB", "rgbValue": "rgb(r, g, b)", "name": "Friendly Color Name", "source": "css_file:style.css" } ] - Error Responses:
400 Bad Request: If the URL parameter is missing or invalid. The body will be aList<ColorInfo>containing a single error object (e.g.,[{"hexValue":null,"rgbValue":null,"name":"URL parameter cannot be empty.","source":"input_validation"}]).500 Internal Server Error: For other server-side issues. The body will also be aList<ColorInfo>containing a single error object.
- Query Parameter:
- The application processes a limited number of images (top 10) and images up to a certain size (5MB) to ensure performance.
- Color extraction from dynamic content loaded by JavaScript after initial page load might be limited as the backend primarily parses static HTML and CSS.
- The color names are based on a standard list of 140 web colors. Colors not on this list (e.g., from images) will typically have their HEX value as their name.