text2image 1.0.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb0d3931cb713209d4e80ca9523e0ef0ce77d48196c0e90cd93c04625b4f6fbd
4
- data.tar.gz: e5ddf3e583a8311733e10c218d3e1e421d44d254c4b9a7c3b331120d36b973c1
3
+ metadata.gz: 40df9be876e9a4bfc5b544e0ee37162168ae00dafa9325f07feb9127c1dec2cc
4
+ data.tar.gz: d176b2852c38366933bcf28f8653b5fddeb4d10977adf857bf5fe100e6b19028
5
5
  SHA512:
6
- metadata.gz: 86ccbdd21981642e01bee9983358dbb2684b89ae454021009f71a24ede88b4b2a8f9075380018cc5315c82b136f25d54b1fa1317c8da1029be6afb1cdf07a50a
7
- data.tar.gz: 32eea1ac4e7840d28bd293f6694eec07ed0c40817561ea60484f3b4843038d19b47f02aed079dc5223e0f4071d478a67758dd68464fbe16ac45198c0d504c6c0
6
+ metadata.gz: 7fdafbbb8ae9b888eab5cd9ac5eb096b3c1e9a5a2d86396e274c3892853690e61ae4bbfe8f4fcdc6373fca7d148b306dbd7063f2482bbec16d647a927a19ecae
7
+ data.tar.gz: 4653155990f44271e2ae537ad390ad1fcf1f44c5268f771b1ca5c92b1fd14a9012684c123212c2285eba15b6ccfc3ae3500e25240ae9feb7bbb2f9bd303dca86
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.3.0] - 2026-01-15
6
+
7
+ ### Added
8
+ - **Multi-format Support**: Support for `png`, `jpg`/`jpeg`, `bmp`, and `webp`.
9
+ - **Customizable Background & Font**: Enhanced options to override default background and system font.
10
+ - **Improved Extension Detection**: Automatically detects output format from the file extension.
11
+
5
12
  ## [1.0.0] - 2026-01-15
6
13
 
7
14
  ### Added
data/CHANGELOG_ko.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.3.0] - 2026-01-15
6
+
7
+ ### Added
8
+ - **Multi-format Support**: Support for `png`, `jpg`/`jpeg`, `bmp`, and `webp`.
9
+ - **Customizable Background & Font**: Enhanced options to override default background and system font.
10
+ - **Improved Extension Detection**: Automatically detects output format from the file extension.
11
+
5
12
  ## [1.0.0] - 2026-01-15
6
13
 
7
14
  ### Added
data/CONTRIBUTING.md CHANGED
@@ -29,7 +29,7 @@ Thank you for your interest in contributing to `text2image`! To contribute, plea
29
29
  To share your development environment:
30
30
 
31
31
  ```bash
32
- git clone https://github.com/rheehose/text2image.git
32
+ git clone https://github.com/hslcrb/rupack_text2image.git
33
33
  cd text2image
34
34
  bin/setup
35
35
  ```
@@ -40,7 +40,7 @@ Everyone interacting in the text2image project's codebases, issue trackers, chat
40
40
 
41
41
  ## Author
42
42
 
43
- - **Rheehose (Rhee Creative)** - *Initial work* - [rheehose](https://github.com/rheehose)
43
+ - **Rheehose (Rhee Creative)** - *Initial work* - [hslcrb](https://github.com/hslcrb)
44
44
 
45
45
  ## License
46
46
 
data/CONTRIBUTING_ko.md CHANGED
@@ -29,7 +29,7 @@ Thank you for your interest in contributing to `text2image`! To contribute, plea
29
29
  To share your development environment:
30
30
 
31
31
  ```bash
32
- git clone https://github.com/rheehose/text2image.git
32
+ git clone https://github.com/hslcrb/rupack_text2image.git
33
33
  cd text2image
34
34
  bin/setup
35
35
  ```
@@ -40,7 +40,7 @@ Everyone interacting in the text2image project's codebases, issue trackers, chat
40
40
 
41
41
  ## Author
42
42
 
43
- - **Rheehose (Rhee Creative)** - *Initial work* - [rheehose](https://github.com/rheehose)
43
+ - **Rheehose (Rhee Creative)** - *Initial work* - [hslcrb](https://github.com/hslcrb)
44
44
 
45
45
  ## License
46
46
 
data/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
 
5
5
  ## Features
6
6
 
7
- - **Text to Image**: Convert any text string into a PNG/JPG image.
8
- - **Auto Font Detection**: Automatically finds the best available system font using `fontconfig`.
7
+ - **Multi-format Support**: Convert text to `png`, `jpg`, `bmp`, or `webp` images.
9
8
  - **Smart Padding**: Calculates the bounding box of the text and adds uniform padding on all four sides.
10
- - **Customizable**: Options for font size, background/foreground colors, and padding width.
9
+ - **Auto Font Detection**: Automatically finds the best available system font using `fontconfig`.
10
+ - **Customizable**: Options for font size, specific font paths, background/foreground colors, and padding width.
11
11
 
12
12
  ## Requirements
13
13
 
@@ -48,13 +48,14 @@ require 'text2image'
48
48
  # Save text to an image file (default 10px padding)
49
49
  Text2image.convert("Hello, World!", output: "hello.png")
50
50
 
51
- # With custom options including padding
51
+ # With custom options including padding and format
52
52
  Text2image.convert("Ruby is Awesome",
53
- output: "ruby.png",
53
+ output: "ruby.webp",
54
54
  font_size: 48,
55
55
  padding: 30,
56
- background: "white",
57
- foreground: "black"
56
+ background: "#f0f0f0",
57
+ foreground: "blue",
58
+ format: "webp"
58
59
  )
59
60
  ```
60
61
 
data/README_ko.md CHANGED
@@ -1,19 +1,17 @@
1
1
  # text2image
2
2
 
3
- `text2image`는 텍스트를 하얀 바탕에 검은색 글꼴로 자동화하여 이미지로 변환해주는 루비(Ruby) 라이브러리입니다. 시스템에 설치된 폰트를 자동으로 탐지하고, 텍스트 크기에 맞춰 여백(Padding)이 포함된 최적의 이미지를 생성합니다.
3
+ `text2image` is a Ruby library that transforms text into black-on-white images. It automatically detects system fonts and generates optimized images with configurable padding around the text.
4
4
 
5
- `text2image` is a Ruby library that transforms text into black-on-white images with automatic system font detection and smart padding adjustment.
5
+ ## Features
6
6
 
7
- ## 주요 기능 (Features)
7
+ - **Multi-format Support**: Convert text to `png`, `jpg`, `bmp`, or `webp` images.
8
+ - **Smart Padding**: Calculates the bounding box of the text and adds uniform padding on all four sides.
9
+ - **Auto Font Detection**: Automatically finds the best available system font using `fontconfig`.
10
+ - **Customizable**: Options for font size, specific font paths, background/foreground colors, and padding width.
8
11
 
9
- - **텍스트-이미지 변환**: 어떤 문자열이든 PNG/JPG 이미지로 변환합니다.
10
- - **자동 폰트 탐지**: `fontconfig`를 사용하여 시스템의 최적 폰트를 자동으로 찾습니다.
11
- - **스마트 여백 (Smart Padding)**: 텍스트의 실제 크기를 계산하여 4방면에 균일한 여백을 자동으로 추가합니다.
12
- - **유연한 설정**: 폰트 크기, 배경색, 글자색, 여백 크기 등을 자유롭게 조절할 수 있습니다.
12
+ ## Requirements
13
13
 
14
- ## 설치 요구사항 (Requirements)
15
-
16
- 이 라이브러리는 **ImageMagick**과 **fontconfig**가 시스템에 설치되어 있어야 합니다.
14
+ This library requires **ImageMagick** and **fontconfig** to be installed on your system.
17
15
 
18
16
  ### Linux (Ubuntu/Debian)
19
17
  ```bash
@@ -26,41 +24,42 @@ sudo apt install imagemagick fontconfig
26
24
  brew install imagemagick fontconfig
27
25
  ```
28
26
 
29
- ## 설치 (Installation)
27
+ ## Installation
30
28
 
31
- `Gemfile`에 다음 줄을 추가하세요:
29
+ Add this line to your application's Gemfile:
32
30
 
33
31
  ```ruby
34
32
  gem 'text2image'
35
33
  ```
36
34
 
37
- 아래 명령어를 실행합니다:
35
+ And then execute:
38
36
 
39
37
  ```bash
40
38
  $ bundle install
41
39
  ```
42
40
 
43
- ## 사용법 (Usage)
41
+ ## Usage
44
42
 
45
- ### 기본 사용 (Basic Usage)
43
+ ### Basic Usage
46
44
 
47
45
  ```ruby
48
46
  require 'text2image'
49
47
 
50
- # 텍스트를 이미지 파일로 저장 (기본 여백 10px 적용)
51
- Text2image.convert("안녕하세요!", output: "hello.png")
52
-
53
- # 옵션 설정 (여백 포함)
54
- Text2image.convert("Ruby",
55
- output: "ruby.png",
56
- font_size: 50,
57
- padding: 20,
58
- background: "white",
59
- foreground: "black"
48
+ # Save text to an image file (default 10px padding)
49
+ Text2image.convert("Hello, World!", output: "hello.png")
50
+
51
+ # With custom options including padding and format
52
+ Text2image.convert("Ruby is Awesome",
53
+ output: "ruby.webp",
54
+ font_size: 48,
55
+ padding: 30,
56
+ background: "#f0f0f0",
57
+ foreground: "blue",
58
+ format: "webp"
60
59
  )
61
60
  ```
62
61
 
63
- ## 저작권 및 라이선스 (License)
62
+ ## License
64
63
 
65
64
  Copyright (c) 2008-2026 Rheehose (Rhee Creative).
66
- 라이브러리는 [MIT License](LICENSE) 하에 배포됩니다.
65
+ Released under the [MIT License](LICENSE).
@@ -4,7 +4,7 @@ require 'mini_magick'
4
4
 
5
5
  module Text2image
6
6
  class Converter
7
- attr_accessor :text, :font, :font_size, :background, :foreground, :padding
7
+ attr_accessor :text, :font, :font_size, :background, :foreground, :padding, :format
8
8
 
9
9
  def initialize(text, options = {})
10
10
  @text = text
@@ -13,16 +13,18 @@ module Text2image
13
13
  @background = options[:background] || "white"
14
14
  @foreground = options[:foreground] || "black"
15
15
  @padding = options[:padding] || 10
16
+ @format = options[:format] || "png"
16
17
  end
17
18
 
18
19
  def render(output_path = nil)
19
20
  require 'tempfile'
20
21
 
21
- # Step 1: Get text dimensions without padding
22
- # We use 'pango' or 'caption' if available for better text handling
23
- # But for simplicity and portability, we use 'label' or 'caption' with trim
22
+ # Determine format from output_path if available, otherwise use @format
23
+ actual_format = output_path ? File.extname(output_path).delete('.').downcase : @format
24
+ actual_format = "png" if actual_format.empty?
24
25
 
25
- temp_raw = Tempfile.new(['text2image_raw', '.png'])
26
+ # Step 1: Get text dimensions without padding
27
+ temp_raw = Tempfile.new(['text2image_raw', ".#{actual_format}"])
26
28
  raw_path = temp_raw.path
27
29
  temp_raw.close
28
30
 
@@ -46,7 +48,7 @@ module Text2image
46
48
  final_width = width + (@padding * 2)
47
49
  final_height = height + (@padding * 2)
48
50
 
49
- temp_final = Tempfile.new(['text2image_final', '.png'])
51
+ temp_final = Tempfile.new(['text2image_final', ".#{actual_format}"])
50
52
  final_path = temp_final.path
51
53
  temp_final.close
52
54
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Text2image
4
- VERSION = "1.0.0"
4
+ VERSION = "1.3.0"
5
5
  end
data/test_result.jpg ADDED
Binary file
data/test_result.png ADDED
Binary file
data/test_result.webp ADDED
Binary file
data/text2image.gemspec CHANGED
@@ -6,11 +6,11 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "text2image"
7
7
  spec.version = Text2image::VERSION
8
8
  spec.authors = ["Rheehose (Rhee Creative)"]
9
- spec.email = ["rheehose@example.com"]
9
+ spec.email = ["rheehose@rheehose.com"]
10
10
 
11
11
  spec.summary = "A Ruby library to convert text to images with automatic system font detection."
12
12
  spec.description = "text2image allows you to easily transform text into black-and-white images using the best available system fonts. Ideal for quick image generation from text data."
13
- spec.homepage = "https://github.com/rheehose/text2image"
13
+ spec.homepage = "https://github.com/hslcrb/rupack_text2image"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
16
16
 
data/verify_work.rb CHANGED
@@ -7,29 +7,29 @@ begin
7
7
  font_path = Text2image.find_font
8
8
  puts "탐지된 시스템 폰트 경로: #{font_path}"
9
9
 
10
- # 2. 이미지 생성 테스트 (스마트 여백 기능 확인)
11
- output_file = "test_padded_result.png"
12
- padding_value = 50
10
+ # 2. 이미지 생성 테스트 (다양한 포맷 옵션 확인)
11
+ formats = ["png", "jpg", "webp"]
13
12
 
14
- puts "이미지 생성 중 (여백: #{padding_value}px)..."
15
- Text2image.convert("Ruby Text2Image\nSmart Padding Test",
16
- output: output_file,
17
- font_size: 40,
18
- padding: padding_value,
19
- background: "white",
20
- foreground: "black"
21
- )
22
-
23
- if File.exist?(output_file)
24
- puts "✅ 성공! 이미지가 생성되었습니다: #{File.expand_path(output_file)}"
13
+ formats.each do |fmt|
14
+ output_file = "test_result.#{fmt}"
15
+ puts "이미지 생성 중 (#{fmt} 포맷)..."
16
+ Text2image.convert("Ruby Text2Image v1.3\nFormat: #{fmt.upcase}",
17
+ output: output_file,
18
+ font_size: 35,
19
+ padding: 20,
20
+ background: (fmt == "webp" ? "#E0F7FA" : "white"),
21
+ foreground: (fmt == "webp" ? "#006064" : "black")
22
+ )
25
23
 
26
- # 3. 실제 이미지 크기 확인 (여백이 잘 들어갔는지 간접 확인)
27
- image = MiniMagick::Image.open(output_file)
28
- puts "생성된 이미지 크기: #{image.width}x#{image.height}"
29
- puts "테스트 완료!"
30
- else
31
- puts "❌ 실패: 이미지가 생성되지 않았습니다."
24
+ if File.exist?(output_file)
25
+ image = MiniMagick::Image.open(output_file)
26
+ puts " 성공! #{fmt.upcase} 생성됨: #{image.width}x#{image.height}"
27
+ else
28
+ puts "❌ 실패: #{fmt.upcase} 생성 실패"
29
+ end
32
30
  end
31
+
32
+ puts "모든 포맷 테스트 완료!"
33
33
 
34
34
  rescue => e
35
35
  puts "❌ 오류 발생: #{e.message}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text2image
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rheehose (Rhee Creative)
@@ -27,7 +27,7 @@ description: text2image allows you to easily transform text into black-and-white
27
27
  using the best available system fonts. Ideal for quick image generation from text
28
28
  data.
29
29
  email:
30
- - rheehose@example.com
30
+ - rheehose@rheehose.com
31
31
  executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
@@ -47,15 +47,18 @@ files:
47
47
  - lib/text2image/font_finder.rb
48
48
  - lib/text2image/version.rb
49
49
  - test_padded_result.png
50
+ - test_result.jpg
51
+ - test_result.png
52
+ - test_result.webp
50
53
  - text2image.gemspec
51
54
  - verify_work.rb
52
- homepage: https://github.com/rheehose/text2image
55
+ homepage: https://github.com/hslcrb/rupack_text2image
53
56
  licenses:
54
57
  - MIT
55
58
  metadata:
56
- homepage_uri: https://github.com/rheehose/text2image
57
- source_code_uri: https://github.com/rheehose/text2image
58
- changelog_uri: https://github.com/rheehose/text2image/blob/main/CHANGELOG.md
59
+ homepage_uri: https://github.com/hslcrb/rupack_text2image
60
+ source_code_uri: https://github.com/hslcrb/rupack_text2image
61
+ changelog_uri: https://github.com/hslcrb/rupack_text2image/blob/main/CHANGELOG.md
59
62
  rdoc_options: []
60
63
  require_paths:
61
64
  - lib