svg2img 0.1.1-aarch64-linux-musl → 0.2.1-aarch64-linux-musl

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: e54c180e6535948703d0cc71112a7f3c1e48955fc6eac2c05aa05033f601019a
4
- data.tar.gz: d14f5bd03ff769a8b2c131f7b59e5591eba0ae161db172c058008c1171519a95
3
+ metadata.gz: 5db2d5e506671b97dbfbc3868b1e014e237abae1f7bd3dc29928ae3eea429bb5
4
+ data.tar.gz: 59bfb924b92e566baa2f4c29f2325c28c02e6de13f6aa19f3c9fc30acd696014
5
5
  SHA512:
6
- metadata.gz: 917ad17cf54ecf2acb71a1452076fc92bf19b3f7b994299acbe0407d446a2b69d2b0e6bb85963061c8bcb86023fc0e9a77b6d044ab46823a1df7be465d812957
7
- data.tar.gz: efc5a174c8999dc7a9169cce898b97358a91e53c8cce083eda7531f12c862486b85b9ecf3c1259876914637052895f444480e4f1900cf6c50d7b3b9cb5a3d187
6
+ metadata.gz: 99c3007746a3332c4ab0232eced31a6edfd0f7b45be098579fbf904f01b5e4ea6176d749842099d8270c573c57d1a9554f0639f7827366ddab949872fbbde50d
7
+ data.tar.gz: d51aab9c2fcb6e84fc7d01d722075e2f53f5e50ffdf9b815e3428755d907c8f920fc1c2628dab7f960f2a41a528a444627e23854dfb1a8215e61a40b86d45f83
data/README.md CHANGED
@@ -40,6 +40,11 @@ bundle lock --add-platform arm64-darwin # Apple Silicon MacOS (i.e. M1)
40
40
 
41
41
  ## Usage
42
42
 
43
+ ```ruby
44
+ require "svg2img"
45
+ Svg2Img.process_svg(svg_string, options)
46
+ ```
47
+
43
48
  Example usage:
44
49
 
45
50
  ```ruby
@@ -50,12 +55,12 @@ circle_svg = <<~SVG
50
55
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
51
56
  </svg>
52
57
  SVG
53
- png_path = Svg2Img.process_svg(circle_svg, output_format: :png)
58
+ png_path = Svg2Img.process_svg(circle_svg, format: :png)
54
59
  # png_path is a path to the generated PNG file
55
60
 
56
61
  # Rails example
57
62
  data = Rails.cache.fetch([some, deps]) do
58
- png_path = Svg2Img.process_svg(circle_svg, output_format: :png)
63
+ png_path = Svg2Img.process_svg(circle_svg, format: :png, size: proc {|_svg_width, _svg_height| [256, 256]})
59
64
  png_data = File.binread(png_path)
60
65
  File.delete(png_path)
61
66
  png_data
@@ -63,6 +68,12 @@ end
63
68
  send_data(png_data, type: 'image/png', disposition: 'inline')
64
69
  ```
65
70
 
71
+ ### Options
72
+
73
+ - `format` - output format, one of `:png`, `:jpg`, `:webp`, `:gif`
74
+ - `output_path` - path to the output image. If not provided, a temporary file will be created and the path to it will be returned.
75
+ - `size` - size of the output image as a proc that receives the width and height of the SVG and returns an array with the width and height of the output image. If the provides size has a different aspect ratio than the SVG, the image will be resized to fit in the center of the provided size. If not provided, the output image will have the same size as the SVG.
76
+
66
77
  ## Development
67
78
 
68
79
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Svg2Img
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg2img
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: aarch64-linux-musl
6
6
  authors:
7
7
  - Orvar Segerström