Create custom attachment processors
masterYou can extend Paperclip by writing custom processors (e.g., for watermarking or encryption).
Requirements:
- Define the class within the
Paperclipmodule. - Inherit from
Paperclip::Processor. - Implement a
makemethod that returns aFile.
Files placed in lib/paperclip or lib/paperclip_processors are automatically loaded. Use the :processors option in has_attached_file to apply them.
# Example usage of a custom :ocr processor
has_attached_file :scan,
styles: { text: { quality: :better } },
processors: [:ocr]Processors are executed in the order defined in the :processors array. Each processor receives the result of the previous one.
has_attached_file :scan, styles: { text: { quality: :better } },
processors: [:ocr]