Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]
## Changelog.md

## [0.1.0] - 2026-01-20

- Initial release
## 0.1.1
- Rails integration documentation
- Optional Railtie for Rails environments
## [0.1.0] - 2026-01-20
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,45 @@ brew install gd
### Gemfile
```bash
gem 'imprint'
```
```



## Rails integration

Imprint is framework-agnostic, but integrates cleanly with Rails.

### Routes

Define your own route:

```ruby
# config/routes.rb
get '/imprint/:token', to: 'imprint#show'
```
### Controller

```ruby
class ImprintController < ApplicationController
def show
path = Imprint.render_from_token(params[:token])

return head :not_found unless path

send_file path, type: 'image/png', disposition: 'inline'
end
end
```

### Usage

```ruby
token = Imprint.sign(
source: '/path/to/image.png',
watermark: 'CONFIDENTIAL',
expires_in: 5.minutes
)
```
```html
<img src="/imprint/<%= token.split('/').last %>" />
```
12 changes: 6 additions & 6 deletions imprint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Gem::Specification.new do |spec|

spec.summary = "Signed, expiring image watermark rendering for Ruby"
spec.description = <<~DESC
Imprint is a Ruby library for generating signed, time-limited image renders
with dynamic text watermarks. It allows you to securely distribute images
using expiring tokens, preventing unauthorized reuse or hotlinking.
Imprint is a Ruby library for generating signed, time-limited image renders
with dynamic text watermarks. It allows you to securely distribute images
using expiring tokens, preventing unauthorized reuse or hotlinking.

Imprint works as a pure Ruby library and can optionally integrate with Rails
via an isolated engine. Image rendering is powered by the GD graphics library.
DESC
Imprint works as a pure Ruby library and can optionally integrate with Rails
via an isolated engine. Image rendering is powered by the GD graphics library.
DESC
spec.homepage = "https://github.com/ggerman/imprint"
spec.license = "MIT"
spec.required_ruby_version = '>= 3.3.0'
Expand Down
1 change: 1 addition & 0 deletions lib/imprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'imprint/signer'
require 'imprint/renderer'
require 'imprint/engine' if defined?(Rails)
require 'imprint/railtie' if defined?(Rails)

module Imprint
def self.sign(source:, watermark:, expires_in:)
Expand Down
14 changes: 14 additions & 0 deletions lib/imprint/rails/helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Imprint
module Rails
module Helper
def imprint_image_tag(token, **)
image_tag(
imprint_render_path(token: token),
**
)
end
end
end
end
17 changes: 17 additions & 0 deletions lib/imprint/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'rails/railtie'

module Imprint
class Railtie < Rails::Railtie
initializer 'imprint.helpers' do
ActiveSupport.on_load(:action_view) do
include Imprint::Rails::Helper
end
end

initializer 'imprint.configure' do
# Punto de extensión futuro
end
end
end