{"id":46109898,"url":"https://github.com/codeminer42/ruby-logo-soup","last_synced_at":"2026-03-01T22:09:15.386Z","repository":{"id":339666395,"uuid":"1162668889","full_name":"Codeminer42/ruby-logo-soup","owner":"Codeminer42","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-20T21:38:55.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-21T02:23:03.133Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Codeminer42.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-20T14:50:35.000Z","updated_at":"2026-02-20T21:38:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Codeminer42/ruby-logo-soup","commit_stats":null,"previous_names":["codeminer42/ruby-logo-soup"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Codeminer42/ruby-logo-soup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codeminer42%2Fruby-logo-soup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codeminer42%2Fruby-logo-soup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codeminer42%2Fruby-logo-soup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codeminer42%2Fruby-logo-soup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codeminer42","download_url":"https://codeload.github.com/Codeminer42/ruby-logo-soup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codeminer42%2Fruby-logo-soup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29986242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T21:06:37.093Z","status":"ssl_error","status_checked_at":"2026-03-01T21:05:45.052Z","response_time":124,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-01T22:09:14.694Z","updated_at":"2026-03-01T22:09:15.376Z","avatar_url":"https://github.com/Codeminer42.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LogoSoup\n\n[![Version](https://img.shields.io/badge/version-0.1.0-blue)](CHANGELOG.md)\n[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE.txt)\n[![Coverage](https://img.shields.io/badge/coverage-86.14%25-brightgreen)](coverage/index.html)\n\nFramework-agnostic Ruby gem for **normalizing logo rendering**.\n\nGiven an input logo (SVG or raster), LogoSoup returns an **inline CSS style string** that you can apply to an `\u003cimg\u003e` (or equivalent) so different logos render with a consistent perceived size, with optional visual-center alignment.\n\nThis gem is inspired by the original Logo Soup project for React ([auroris/logo-soup](https://github.com/auroris/logo-soup)) developed by [Rostislav Melkumyan](https://www.sanity.io/blog/the-logo-soup-problem).\n\n## Why\n\nLogos often have different intrinsic sizes, padding, and visual weight. If you render them at the same width/height, they still *look* inconsistent.\n\nLogoSoup aims to:\n\n- Normalize sizing so logos look consistent at a given `base_size`.\n- Optionally align by visual center (e.g., Y axis) for better baseline alignment.\n- Stay framework-agnostic (no Rails dependencies).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'logosoup'\n```\n\nThen:\n\n```sh\nbundle install\n```\n\nOr, with Bundler:\n\n```sh\nbundle add logosoup\n```\n\n## Requirements\n\n- Ruby: `\u003e= 2.7`, `\u003c 4.0`\n- System dependency: **libvips** (required for raster analysis)\n\n### Installing libvips\n\n- macOS (Homebrew):\n\n```sh\nbrew install vips\n```\n\n- Ubuntu/Debian:\n\n```sh\nsudo apt-get update \u0026\u0026 sudo apt-get install -y libvips\n```\n\n## Usage\n\nLogoSoup exposes a single entrypoint: `LogoSoup.style`.\n\n### SVG (string)\n\n```ruby\nstyle = LogoSoup.style(\n\n  svg: File.read('logo.svg'),\n  base_size: 48\n)\n\n# =\u003e \"width: 48px; height: 48px; object-fit: contain; display: block; transform: translate(0px, 0px);\"\n```\n\n### Raster image (file path)\n\n```ruby\nstyle = LogoSoup.style(\n  image_path: 'logo.png',\n  base_size: 48\n)\n```\n\n### Bytes (IO/String)\n\n```ruby\nbytes = File.binread('logo.webp')\n\nstyle = LogoSoup.style(\n  image_bytes: bytes,\n  content_type: 'image/webp',\n  base_size: 48\n)\n```\n\nIf `content_type` includes `svg` (e.g. `image/svg+xml`), `image_bytes:` is treated as SVG and handled by the SVG pipeline.\n\n## API\n\n### `LogoSoup.style`\n\n```ruby\nLogoSoup.style(\n  svg: nil,\n  image_path: nil,\n  image_bytes: nil,\n  content_type: nil,\n  base_size:,\n  on_error: nil,\n  **options\n)\n```\n\n#### Inputs (choose one)\n\n- `svg:` String containing SVG XML\n- `image_path:` filesystem path to an image (PNG/JPG/WebP/GIF/TIFF, etc.)\n- `image_bytes:` String/IO of image bytes\n\n#### Required\n\n- `base_size:` Integer (pixels). Used as the normalization target and also as fallback width/height.\n\n#### Error handling\n\n- `on_error: nil` (default): return a fallback style (`width/height = base_size`, no transform)\n- `on_error: :raise`: re-raise the original exception\n\n#### Options (with defaults)\n\nThese map directly to `LogoSoup::Style::DEFAULTS`:\n\n- `scale_factor:` `0.5`\n- `density_aware:` `true`\n- `density_factor:` `0.5`\n- `contrast_threshold:` `10`\n- `align_by:` `'visual-center-y'`\n- `pixel_budget:` `2048`\n\nNotes:\n\n- Raster images are analyzed with libvips to estimate features (e.g. pixel density / content box / visual center offsets) that inform sizing and transforms.\n- For SVG input, LogoSoup currently uses intrinsic SVG dimensions and skips raster feature measurement.\n\n## Output\n\nThe return value is a single inline CSS string including (at least):\n\n- `width: ...px;`\n- `height: ...px;`\n- `object-fit: contain;`\n- `display: block;`\n- `transform: ...` (only when alignment produces a non-nil transform)\n\nThis is designed to be applied directly to an `\u003cimg\u003e` tag or any element that supports these properties.\n\n## Testing\n\nRun the test suite:\n\n```sh\nbundle exec rake spec\n```\n\n### Coverage\n\nGenerate a local coverage report:\n\n```sh\nbundle exec rake spec:coverage\n```\n\nThis writes HTML reports to `coverage/index.html`.\n\nThe badge at the top of this README reflects the last recorded SimpleCov result in `coverage/.last_run.json` (current line coverage: **86.14%**; branch coverage in that file: **53.17%**).\n\n## Development\n\n```sh\nbundle install\nbundle exec rake spec\n```\n\n## Contributing\n\nBug reports and pull requests are welcome.\n\n- Keep changes focused and add specs where it makes sense.\n- If you change behavior, update `CHANGELOG.md`\n\n## License\n\nReleased under the MIT License. See `LICENSE.txt`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeminer42%2Fruby-logo-soup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeminer42%2Fruby-logo-soup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeminer42%2Fruby-logo-soup/lists"}