Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/renyijiu/douyin_image
A gem for generate douyin style image 😊
https://github.com/renyijiu/douyin_image
douyin images ruby-gem
Last synced: about 16 hours ago
JSON representation
A gem for generate douyin style image 😊
- Host: GitHub
- URL: https://github.com/renyijiu/douyin_image
- Owner: renyijiu
- License: mit
- Created: 2018-09-03T13:21:07.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-04T14:43:31.000Z (about 6 years ago)
- Last Synced: 2024-10-30T00:09:43.553Z (22 days ago)
- Topics: douyin, images, ruby-gem
- Language: Ruby
- Size: 5.74 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.com/renyijiu/douyin_image.svg?branch=master)](https://travis-ci.com/renyijiu/douyin_image)
[![Gem Version](https://badge.fury.io/rb/douyin_image.svg)](https://badge.fury.io/rb/douyin_image)
[![Maintainability](https://api.codeclimate.com/v1/badges/77fc5413d4cc1b2ecc2d/maintainability)](https://codeclimate.com/github/renyijiu/douyin_image/maintainability)⚠️ 图片处理依赖于[ruby-vips](https://github.com/jcupitt/ruby-vips),请确保使用前电脑已正确安装[libvips](https://github.com/jcupitt/libvips)
# DouyinImage
生成抖音风格的图片。Have Fun!😊
## 安装
在你的Gemfile中添加下列代码:
```ruby
gem 'douyin_image'
```然后执行下列命令:
```shell
$ bundle
```或者是使用下列命令直接安装gem:
```shell
$ gem install douyin_image
```## 使用
### 方法调用
当你需要在项目中使用时,可以通过下列代码进行调用:
```ruby
# generate Douyin style image with the input image
#
# @param file_path String - image file path
# @param output_path String - output directory, default: same with input file
# 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})
#DouyinImage.generate(file_path, output_path=nil, options={})
```### 命令行
你也可以通过下列命令查看支持的选项以及操作
```shell
$ douyin --helpUsage: douyin [options]
Specific options:
-i, --input IMAGE_PATH the input image's path
-o, --output [OUTPUT_PATH] the custom output path
-f, --offset [OFFSET] the R channel image offset
-c, --count [COUNT] the small part's count
-w, --width [WIDTH] the small part's width
-h, --height [HEIGHT] the small part's heightCommon options:
--help Show the help message
--version Show version
```## 例子
```ruby
命令行调用:
$ bundle exec douyin -i './tmp/input.jpg' -o './tmp/' -f 20 -c 10或者是:
DouyinImage.generate('./tmp/input.jpg', './tmp/', {offset: 20, part_count: 10})
```### 输入图片
![](./tmp/input.jpg)
输出结果
![](./tmp/input_douyin.jpg)
## 如何贡献
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request欢迎贡献相关代码或是反馈使用时遇到的问题👏,另外请记得为你的代码编写测试。