{"id":15064599,"url":"https://github.com/stevenbarragan/croppable","last_synced_at":"2025-04-14T20:31:55.134Z","repository":{"id":133029302,"uuid":"610058249","full_name":"stevenbarragan/croppable","owner":"stevenbarragan","description":"Easily crop images in Ruby on Rails with Cropper.js integration.","archived":false,"fork":false,"pushed_at":"2024-11-27T19:47:55.000Z","size":189,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T08:42:29.539Z","etag":null,"topics":["cropper","cropperjs","image-manipulation","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/croppable","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/stevenbarragan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-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}},"created_at":"2023-03-06T01:57:05.000Z","updated_at":"2024-11-27T19:47:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"68092cf4-f8a5-4710-ae2a-45e5b46ce4be","html_url":"https://github.com/stevenbarragan/croppable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenbarragan%2Fcroppable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenbarragan%2Fcroppable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenbarragan%2Fcroppable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenbarragan%2Fcroppable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevenbarragan","download_url":"https://codeload.github.com/stevenbarragan/croppable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248955748,"owners_count":21189221,"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":["cropper","cropperjs","image-manipulation","ruby-on-rails"],"created_at":"2024-09-25T00:22:14.383Z","updated_at":"2025-04-14T20:31:55.114Z","avatar_url":"https://github.com/stevenbarragan.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Croppable\nEasily crop images in Ruby on Rails with [Cropper.js](https://fengyuanchen.github.io/cropperjs/v2/) integration.\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"croppable\"\n```\n\n## Setup\n```bash\nbin/rails croppable:install\n```\n\n## Manual setup\nInstall cropperjs JavaScript dependency\n```\nyarn add cropperjs@next\n// or\nbin/importmap pin cropperjs@next\n```\n\nIf you're using importmap add croppable pin to importmap.rb\n```ruby\npin \"croppable\"\n```\n\nImport the croppable JavaScript module in your application entrypoint\n```js\nimport \"croppable\"\n```\n\nImport croppable styles in your base stylesheet\n```\n*= require croppable\n```\n\nInstall croppable migrations\n```\nbin/rails croppable:install:migrations\n```\n\n## Install [libvips](https://www.libvips.org/install.html)\n```bash\nbrew install vips\n```\n\n## Usage\nAdd has_croppable into your model\n```ruby\ninclude Croppable::Model\n\nhas_croppable :logo, width: 300, height: 300, scale: 2\n\n# Using predefined variants\nhas_croppable :logo, width: 300, height: 300, scale: 2 do |attachable|\n attachable.variant :thumb, resize_to_fill: [100, 100]\n attachable.variant :medium, resize_to_fill: [300, 300]\nend\n```\n\n`width` and `height` are in pixels and required.\n\n`scale: 2` will generate an image twice as big. Useful for retina display monitors. It defaults to 1.\n\nThe block is passed to `has_one_attached`, supporting [Rails 7's predefined\nvariant blocks](https://github.com/rails/rails/pull/39135). If you're using\ncroppable's `scale` option with a value \u003e 1, you'll have to do the math\nyourself for the variant dimensions to match the base scaled image. See the\n[ImageProcessing docs](https://github.com/janko/image_processing/tree/master)\nfor the processing options.\n\nAdd croppable_field to your form\n```ruby\nform.croppable_field :logo\n```\n\nUpdate controller strong paramenters to permit each croppable parameter\n```ruby\ninclude Croppable::PermittableParams\n\nparams.require(:model).permit(..., logo: croppable_params)\n```\n\nDisplay cropped image in your view\n```ruby\nimage_tag model.logo if model.logo.present?\n```\n\nOriginal image can be accessed in \\\u003ccroppable\\\u003e_original\n```ruby\nmodel.logo_original\n```\n\nConfiguration on global defaults can be done in an initializer:\n\n```ruby\nRails.application.config.to_prepare do\n  Croppable.config.default_scale = 2 # default 1\n  Croppable.config.image_quality = 80 # default 100\nend\n```\n\nNOTE: Images are cropped in a background job after model gets saved so they might not be immediately available\n\n## Contributing\n\nRun all test\n```bash\nrails test\nrails app:test:system\n```\n\n## License\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenbarragan%2Fcroppable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenbarragan%2Fcroppable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenbarragan%2Fcroppable/lists"}