Module: DouyinImage

Defined in:
lib/douyin_image.rb,
lib/douyin_image/image.rb,
lib/douyin_image/version.rb

Defined Under Namespace

Classes: Image

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.generate(file_path, output_path = nil, options = {}) ⇒ Object

generate Douyin style image with the input image

options:

offset: the R channel image offset, default: 8
part_count: the small part's count, default: rand(5..10)
part_width: the small part's width, default: rand(10..30)
part_height: the small part's height, default: rand(10..30)

Example:

DouyinImage.generate('./test.jpg', './test/', {offset: 10})

Parameters:

  • file_path

    String - image file path

  • output_path (defaults to: nil)

    String - output directory, default: same with input file

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
# File 'lib/douyin_image.rb', line 22

def generate(file_path, output_path=nil, options={})
  raise ArgumentError, 'File not exist, please check the file path' unless File.file?(file_path)
  output_path = get_output_filepath(file_path, output_path)

  Image.new.generate(file_path, output_path, options)
  puts "图片生成完成,去看看吧😊!#{output_path}"
end