{"_id":"@cairoramos7/image-hues","_rev":"4-b49d1e931d8a3a032b79b13ecf5721b6","name":"@cairoramos7/image-hues","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@cairoramos7/image-hues","version":"1.0.0","keywords":["image","color","dominant","contrast","palette"],"author":{"url":"https://github.com/cairoramos7","name":"Cairo Ramos","email":"cairoramos7@gmail.com"},"license":"MIT","_id":"@cairoramos7/image-hues@1.0.0","maintainers":[{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"}],"homepage":"https://github.com/cairoramos7/image-hues#readme","bugs":{"url":"https://github.com/cairoramos7/image-hues/issues"},"dist":{"shasum":"d32e0e3b20de3fde8a47b6d2a54ad0bbd3ff5e86","tarball":"https://registry.npmjs.org/@cairoramos7/image-hues/-/image-hues-1.0.0.tgz","fileCount":4,"integrity":"sha512-hHWND4VMez3VDbUDPOo188XsxGT3I0XDgK1L7fvZ6LXG2W3TJvXZZaEjZFv5+NdubIgZ8m1dsa4XknkdBXVVjQ==","signatures":[{"sig":"MEYCIQDV7kCRB69qb16MHAs+viV62lekXvWLpiq7poCXFRxklAIhAPIBPTUMYPRC1h0dSBsORyxg8XtUuQwwwHRc4lwUm4pM","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12234},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"jest","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"},"repository":{"url":"git+https://github.com/cairoramos7/image-hues.git","type":"git"},"_npmVersion":"10.9.2","description":"Extract dominant colors and contrast colors from images","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","ts-jest":"^29.0.0","typescript":"^5.0.0","@types/jest":"^29.0.0"},"_npmOperationalInternal":{"tmp":"tmp/image-hues_1.0.0_1747225241627_0.2412309611382344","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package has been renamed to image-hues. Please install image-hues instead."},"1.0.1":{"name":"@cairoramos7/image-hues","version":"1.0.1","keywords":["image","color","dominant","contrast","palette"],"author":{"url":"https://github.com/cairoramos7","name":"Cairo Ramos","email":"cairoramos7@gmail.com"},"license":"MIT","_id":"@cairoramos7/image-hues@1.0.1","maintainers":[{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"}],"homepage":"https://github.com/cairoramos7/image-hues#readme","bugs":{"url":"https://github.com/cairoramos7/image-hues/issues"},"dist":{"shasum":"9a7b19cfb5ca0dd6741b8f942083f0d38e310838","tarball":"https://registry.npmjs.org/@cairoramos7/image-hues/-/image-hues-1.0.1.tgz","fileCount":5,"integrity":"sha512-nIRrOCW3dywsFhaVzgWj8uf2MOwflUzep6eVoO65TLuq2jhtvys0i5zk6TpH4PZTKbdTsWTldD3IlN4QmWrrfw==","signatures":[{"sig":"MEUCIQDFBe1tPYPjOARG6ZzQWPf+ynkwbCxdlfZXLmfZK+ZvegIgMwgpdhe7hKlJ/i8s40LiJ5eW3RdrvEpGZwnpYoM3XLo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13302},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"c36514283cdb49be3b56d6fe5f8bf34d0397aa21","scripts":{"test":"jest","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"},"repository":{"url":"git+https://github.com/cairoramos7/image-hues.git","type":"git"},"_npmVersion":"8.19.4","description":"Extract dominant colors and contrast colors from images","directories":{},"_nodeVersion":"16.20.2","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","ts-jest":"^29.0.0","typescript":"^5.0.0","@types/jest":"^29.0.0"},"_npmOperationalInternal":{"tmp":"tmp/image-hues_1.0.1_1747226089124_0.9731159166055121","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package has been renamed to image-hues. Please install image-hues instead."},"1.0.3":{"name":"@cairoramos7/image-hues","version":"1.0.3","keywords":["image","color","dominant","contrast","palette"],"author":{"url":"https://github.com/cairoramos7","name":"Cairo Ramos","email":"cairoramos7@gmail.com"},"license":"MIT","_id":"@cairoramos7/image-hues@1.0.3","maintainers":[{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"}],"homepage":"https://github.com/cairoramos7/image-hues#readme","bugs":{"url":"https://github.com/cairoramos7/image-hues/issues"},"dist":{"shasum":"1c8824b93e0502e945c39f1b3fe14027b2f00de6","tarball":"https://registry.npmjs.org/@cairoramos7/image-hues/-/image-hues-1.0.3.tgz","fileCount":9,"integrity":"sha512-UhBuPDAitZrHxMQ923TUjYftzt/VOrT9c9e/tcv8zEFnkXZ8idwr88oviAHKFN/+GyfIAcNmWPxnHguHaiBaHw==","signatures":[{"sig":"MEUCIQC+uFmBd0hs6nWrMrEbxQMVI2PFMrh1uNkxoY/wnDp3MwIgH1KIwuNeFQ1XhVj+daAOfnMEka882jQvBN/B3oHaZM0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18147},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"c583bce6d912015c57a68a1d8b2efa654ccd24b6","scripts":{"test":"jest","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"},"repository":{"url":"git+https://github.com/cairoramos7/image-hues.git","type":"git"},"_npmVersion":"8.19.4","description":"Extract dominant colors and contrast colors from images","directories":{},"_nodeVersion":"16.20.2","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.3.2","typescript":"^5.0.0","@types/jest":"^29.5.14","jest-canvas-mock":"^2.5.2","jest-environment-jsdom":"^29.7.0"},"_npmOperationalInternal":{"tmp":"tmp/image-hues_1.0.3_1747250670655_0.6106237540638815","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package has been renamed to image-hues. Please install image-hues instead."}},"time":{"created":"2025-05-14T12:20:41.560Z","modified":"2025-05-15T20:02:55.244Z","1.0.0":"2025-05-14T12:20:41.818Z","1.0.1":"2025-05-14T12:34:49.329Z","1.0.3":"2025-05-14T19:24:30.865Z"},"bugs":{"url":"https://github.com/cairoramos7/image-hues/issues"},"author":{"url":"https://github.com/cairoramos7","name":"Cairo Ramos","email":"cairoramos7@gmail.com"},"license":"MIT","homepage":"https://github.com/cairoramos7/image-hues#readme","keywords":["image","color","dominant","contrast","palette"],"repository":{"url":"git+https://github.com/cairoramos7/image-hues.git","type":"git"},"description":"Extract dominant colors and contrast colors from images","maintainers":[{"name":"cairoramos7","email":"cairo.ramosoliveira4@gmail.com"}],"readme":"# Image Hues\n\n[![npm version](https://badge.fury.io/js/@cairoramos7%2Fimage-hues.svg)](https://www.npmjs.com/package/@cairoramos7/image-hues)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![GitHub issues](https://img.shields.io/github/issues/cairoramos7/image-hues)](https://github.com/cairoramos7/image-hues/issues)\n\n**Image Hues** is a lightweight TypeScript library for extracting dominant colors and their contrast colors from images. It supports both raster images (e.g., PNG, JPEG) and SVG files, making it ideal for web developers building dynamic UI components, color palettes, or accessibility-focused designs.\n\n## Features\n\n- Extracts the top dominant colors from an image.\n- Generates contrast colors (black or white) based on luminance for accessibility.\n- Supports sampling for performance optimization.\n- Handles SVG images with fallback colors.\n- TypeScript support with full type definitions.\n- No external dependencies, works in modern browsers.\n\n## Installation\n\nInstall the package via npm:\n\n```bash\nnpm install @cairoramos7/image-hues\n```\n\n## Usage\n\n### Basic Example\n\nExtract the dominant colors and contrast colors from an image URL:\n\n```javascript\nimport { getImageDominantColors } from '@cairoramos7/image-hues';\n\ngetImageDominantColors('https://example.com/image.jpg')\n  .then(result => {\n    console.log(result);\n    // Example output:\n    // {\n    //   mainColors: ['#ff0000', '#00ff00', '#0000ff'],\n    //   contrastColors: ['#ffffff', '#000000', '#ffffff']\n    // }\n  })\n  .catch(error => console.error(error));\n```\n\n### Custom Parameters\n\nSpecify the sample size and number of colors:\n\n```javascript\nimport { getImageDominantColors } from '@cairoramos7/image-hues';\n\ngetImageDominantColors('https://example.com/image.jpg', 5, 5)\n  .then(result => {\n    console.log(result);\n    // Returns 5 dominant colors with a sample size of 5\n  })\n  .catch(error => console.error(error));\n```\n\n### Advanced Usage\n\nCreate a custom extractor instance for more control:\n\n```javascript\nimport { createDominantColorExtractor } from '@cairoramos7/image-hues';\n\nconst extractor = createDominantColorExtractor();\nextractor.extract('https://example.com/image.jpg', 10, 3)\n  .then(result => {\n    console.log(result);\n  })\n  .catch(error => console.error(error));\n```\n\n## API\n\n### getImageDominantColors(imageUrl: string, sampleSize?: number, colorCount?: number)\n\nExtracts dominant colors and their contrast colors from an image.\n\n**Parameters:**\n- `imageUrl`: The URL of the image (e.g., PNG, JPEG, SVG).\n- `sampleSize` (optional, default: 10): Sampling rate for pixel analysis (higher values improve performance but may reduce accuracy).\n- `colorCount` (optional, default: 3): Number of dominant colors to return.\n\n**Returns:** A Promise resolving to an object with:\n- `mainColors`: Array of hex color codes (e.g., ['#ff0000', '#00ff00']).\n- `contrastColors`: Array of contrast colors (e.g., ['#ffffff', '#000000']).\n\n**Throws:** Errors for invalid images, failed loads, or canvas issues.\n\n### createDominantColorExtractor(): ColorExtractor\n\nCreates a reusable ColorExtractor instance for custom processing.\n\n**Returns:** An object with an extract method matching getImageDominantColors.\n\n## Requirements\n\n- Modern browser environment (supports Image and Canvas APIs).\n- ES2017+ for Object.entries (ensured via TypeScript configuration).\n\n## Installation Notes\n\n- Ensure images are accessible with CORS (crossOrigin=\"Anonymous\" is set).\n- SVG support is limited to fallback colors due to canvas limitations.\n\n## Contributing\n\nContributions are welcome! Follow these steps:\n\n1. Fork the repository: https://github.com/cairoramos7/image-hues.\n2. Create a feature branch: `git checkout -b feature/your-feature`.\n3. Commit changes: `git commit -m \"Add your feature\"`.\n4. Push to the branch: `git push origin feature/your-feature`.\n5. Open a Pull Request.\n\nPlease read CONTRIBUTING.md for details and code of conduct.\n\n## Issues\n\nReport bugs or suggest features at [GitHub Issues](https://github.com/cairoramos7/image-hues/issues).\n\n## License\n\nThis project is licensed under the MIT License. See LICENSE for details.\n\n## Author\n\nCairo Ramos @cairoramos7\n\n## Acknowledgments\n\n- Built with TypeScript for type safety and maintainability.\n- Inspired by color extraction libraries like color-thief and vibrant.js.\n\nHappy color extracting! 🎨","readmeFilename":"README.md"}