Module: ThumbGen::Test

Defined in:
lib/thumb_gen/test.rb

Overview

rubocop:disable all

Class Method Summary collapse

Class Method Details

.generate_sampleObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/thumb_gen/test.rb', line 8

def self.generate_sample
  output_path = 'sample_output.jpg'
  background_url = 'sample_input.jpg'
  texts = [
    {
      text: 'ThumbGen is a Ruby gem that simplifies the creation of article thumbnails',
      wrapped_width: 800,
      font: 'PublicSans-Bold',
      font_size: 80,
      color: '#047857',
      outline_color: '#f8fafc',
      outline_width: 1,
      gravity: 'northwest',
      position_x: 40,
      position_y: 120
    },
    {
      text: '5 min read',
      wrapped_width: 800,
      font: 'Roboto-Italic',
      font_size: 48,
      color: '#09090b',
      gravity: 'southwest',
      position_x: 400,
      position_y: 40
    },
    {
      text: 'My Blog',
      wrapped_width: 1280,
      font: 'Roboto-BoldItalic',
      font_size: 64,
      color: '#86198f',
      gravity: 'northeast',
      position_x: 200,
      position_y: 30
    }
  ]
  options = {
    width: 1280,
    height: 720,
    format: 'jpg'
  }
  ThumbGen::Generator.new(output_path, background_url, texts, options).generate
end