{"id":17220500,"url":"https://github.com/teeparham/paperclip-meta","last_synced_at":"2025-04-12T14:57:31.437Z","repository":{"id":657786,"uuid":"958488","full_name":"teeparham/paperclip-meta","owner":"teeparham","description":"Adds width, height, and size to paperclip images.","archived":false,"fork":false,"pushed_at":"2022-12-09T08:24:59.000Z","size":191,"stargazers_count":158,"open_issues_count":10,"forks_count":97,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-30T03:42:57.403Z","etag":null,"topics":["images","paperclip","rails","ruby"],"latest_commit_sha":null,"homepage":"","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/teeparham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-10-03T15:03:24.000Z","updated_at":"2024-03-18T23:01:39.000Z","dependencies_parsed_at":"2023-01-13T10:34:31.361Z","dependency_job_id":null,"html_url":"https://github.com/teeparham/paperclip-meta","commit_stats":null,"previous_names":["y8/paperclip-meta"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teeparham%2Fpaperclip-meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teeparham%2Fpaperclip-meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teeparham%2Fpaperclip-meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teeparham%2Fpaperclip-meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teeparham","download_url":"https://codeload.github.com/teeparham/paperclip-meta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586250,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["images","paperclip","rails","ruby"],"created_at":"2024-10-15T03:52:28.849Z","updated_at":"2025-04-12T14:57:31.396Z","avatar_url":"https://github.com/teeparham.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Paperclip Meta\n\n[![Gem Version](https://badge.fury.io/rb/paperclip-meta.svg)](http://rubygems.org/gems/paperclip-meta)\n[![Build Status](https://travis-ci.org/teeparham/paperclip-meta.svg?branch=master)](https://travis-ci.org/teeparham/paperclip-meta)\n\nAdd width, height, and size to paperclip images.\n\nPaperclip Meta gets image dimensions after `post_process_styles` using paperclip's `Geometry.from_file`.\n\nPaperclip Meta works with paperclip version 5.x and 6.x.\n\nVersion 2.x works with paperclip version 4.x.\n\n### Setup\n\nAdd paperclip-meta to Gemfile:\n\n```ruby\ngem 'paperclip-meta'\n```\n\nCreate migration to add a *_meta column:\n\n```ruby\nclass AddAvatarMetaToUsers \u003c ActiveRecord::Migration\n  def change\n    add_column :users, :avatar_meta, :text\n  end\nend\n```\n\nRebuild all thumbnails to populate the meta column if you already have some attachments.\n\nNow you can grab the size from the paperclip attachment:\n\n```ruby\nimage_tag user.avatar.url, size: user.avatar.image_size\nimage_tag user.avatar.url(:medium), size: user.avatar.image_size(:medium)\nimage_tag user.avatar.url(:thumb), size: user.avatar.image_size(:thumb)\n```\n\n### Internals\n\nThe meta column is simple hash:\n\n```ruby\nstyle: {\n  width:  100,\n  height: 100,\n  size:   42000\n}\n```\n\nThis hash will be marshaled and base64 encoded before writing to model attribute.\n\n`height`, `width`, `image_size` and `aspect_ratio` methods are provided:\n\n```ruby\nuser.avatar.width(:thumb)\n=\u003e 100\nuser.avatar.height(:medium)\n=\u003e 200\nuser.avatar.image_size\n=\u003e '60x70'\nuser.avatar.aspect_ratio\n=\u003e 1.5\n```\n\nYou can pass the image style to these methods. If a style is not passed, the default style will be used.\n\n### Alternatives\n\nhttps://github.com/thoughtbot/paperclip/wiki/Extracting-image-dimensions\n\n### Development\n\nTest:\n\n```sh\nbundle\nbundle exec rake\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteeparham%2Fpaperclip-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteeparham%2Fpaperclip-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteeparham%2Fpaperclip-meta/lists"}