fakeimage 0.9
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 +7 -0
- data/.rubocop.yml +30 -0
- data/.ruby-version +1 -0
- data/Dockerfile +28 -0
- data/DroidSans.ttf +0 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +70 -0
- data/Procfile +1 -0
- data/README.md +50 -0
- data/bin/fakeimage +3 -0
- data/config.ru +4 -0
- data/docker-compose.yml +8 -0
- data/fakeimage.rb +80 -0
- data/public/favicon.ico +0 -0
- metadata +159 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 251864b3a5211070db2db39486fc17a134e0c4219eede44d72a46b81f580ee94
|
|
4
|
+
data.tar.gz: ccd269b1f1df9e655ba34a312ba470bc7891d6a9750f7fcd175fc9defc81b9fd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b27856e9ec5ceb835eda8dcfb02a7720f9fab4eadf4064006fe1e92542758687e8c13e76d23ea6f4796122097ad8b609661b439abead02a6e9b46e803153a8be
|
|
7
|
+
data.tar.gz: 2f772913b38f46d3a9591f22e7babfdc2ec8baaa5deb98416a8cf1ebcf0a70705ee00349a9329585750147c75b856c2ebfc8f66e2e3edb80c45fe1bf22db9ca6
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-performance
|
|
3
|
+
- rubocop-rake
|
|
4
|
+
|
|
5
|
+
AllCops:
|
|
6
|
+
NewCops: enable
|
|
7
|
+
|
|
8
|
+
Layout/LineLength:
|
|
9
|
+
Max: 120
|
|
10
|
+
|
|
11
|
+
Metrics/AbcSize:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
Metrics/BlockLength:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
Metrics/ClassLength:
|
|
18
|
+
Enabled: false
|
|
19
|
+
|
|
20
|
+
Metrics/CyclomaticComplexity:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
Metrics/PerceivedComplexity:
|
|
24
|
+
Enabled: false
|
|
25
|
+
|
|
26
|
+
Metrics/MethodLength:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
Style/Documentation:
|
|
30
|
+
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.6
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM library/ruby:3.1.2-alpine
|
|
2
|
+
MAINTAINER Michael Dungan <mpd@jesters-court.net>
|
|
3
|
+
|
|
4
|
+
RUN gem update bundler && \
|
|
5
|
+
apk add --no-cache \
|
|
6
|
+
build-base \
|
|
7
|
+
dumb-init \
|
|
8
|
+
gcc \
|
|
9
|
+
git \
|
|
10
|
+
imagemagick \
|
|
11
|
+
imagemagick-dev \
|
|
12
|
+
wget && \
|
|
13
|
+
mkdir /srv/fakeimage
|
|
14
|
+
|
|
15
|
+
COPY Gemfile \
|
|
16
|
+
Gemfile.lock \
|
|
17
|
+
fakeimage.gemspec \
|
|
18
|
+
/srv/fakeimage/
|
|
19
|
+
WORKDIR /srv/fakeimage
|
|
20
|
+
RUN bundle config github.https true && \
|
|
21
|
+
bundle install && \
|
|
22
|
+
apk del build-base gcc wget
|
|
23
|
+
|
|
24
|
+
COPY . /srv/fakeimage
|
|
25
|
+
|
|
26
|
+
EXPOSE 4567
|
|
27
|
+
|
|
28
|
+
CMD ["dumb-init", "ruby", "fakeimage.rb", "-o", "0.0.0.0"]
|
data/DroidSans.ttf
ADDED
|
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
fakeimage (0.9)
|
|
5
|
+
puma
|
|
6
|
+
rmagick
|
|
7
|
+
sinatra
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
ast (2.4.2)
|
|
13
|
+
coderay (1.1.3)
|
|
14
|
+
method_source (1.0.0)
|
|
15
|
+
mustermann (1.1.1)
|
|
16
|
+
ruby2_keywords (~> 0.0.1)
|
|
17
|
+
nio4r (2.5.8)
|
|
18
|
+
parallel (1.22.1)
|
|
19
|
+
parser (3.1.2.0)
|
|
20
|
+
ast (~> 2.4.1)
|
|
21
|
+
pry (0.14.1)
|
|
22
|
+
coderay (~> 1.1)
|
|
23
|
+
method_source (~> 1.0)
|
|
24
|
+
puma (5.6.4)
|
|
25
|
+
nio4r (~> 2.0)
|
|
26
|
+
rack (2.2.3.1)
|
|
27
|
+
rack-protection (2.2.0)
|
|
28
|
+
rack
|
|
29
|
+
rainbow (3.1.1)
|
|
30
|
+
regexp_parser (2.5.0)
|
|
31
|
+
rexml (3.2.5)
|
|
32
|
+
rmagick (4.2.5)
|
|
33
|
+
rubocop (1.30.0)
|
|
34
|
+
parallel (~> 1.10)
|
|
35
|
+
parser (>= 3.1.0.0)
|
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
37
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
38
|
+
rexml (>= 3.2.5, < 4.0)
|
|
39
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
|
40
|
+
ruby-progressbar (~> 1.7)
|
|
41
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
42
|
+
rubocop-ast (1.18.0)
|
|
43
|
+
parser (>= 3.1.1.0)
|
|
44
|
+
rubocop-performance (1.14.0)
|
|
45
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
46
|
+
rubocop-ast (>= 0.4.0)
|
|
47
|
+
rubocop-rake (0.6.0)
|
|
48
|
+
rubocop (~> 1.0)
|
|
49
|
+
ruby-progressbar (1.11.0)
|
|
50
|
+
ruby2_keywords (0.0.5)
|
|
51
|
+
sinatra (2.2.0)
|
|
52
|
+
mustermann (~> 1.0)
|
|
53
|
+
rack (~> 2.2)
|
|
54
|
+
rack-protection (= 2.2.0)
|
|
55
|
+
tilt (~> 2.0)
|
|
56
|
+
tilt (2.0.10)
|
|
57
|
+
unicode-display_width (2.1.0)
|
|
58
|
+
|
|
59
|
+
PLATFORMS
|
|
60
|
+
ruby
|
|
61
|
+
|
|
62
|
+
DEPENDENCIES
|
|
63
|
+
fakeimage!
|
|
64
|
+
pry
|
|
65
|
+
rubocop
|
|
66
|
+
rubocop-performance
|
|
67
|
+
rubocop-rake
|
|
68
|
+
|
|
69
|
+
BUNDLED WITH
|
|
70
|
+
2.3.15
|
data/Procfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
web: bundle exec rackup config.ru -p $PORT
|
data/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# fakeimage
|
|
2
|
+
|
|
3
|
+
A small Sinatra app influenced by <http://dummyimage.com>.
|
|
4
|
+
|
|
5
|
+
Try it online at [http://fakeimage.herokuapp.com](http://fakeimage.herokuapp.com)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Requires ruby 2.7+. May work with older versions, but not tested or supported.
|
|
10
|
+
|
|
11
|
+
#### Via RubyGems
|
|
12
|
+
```bash
|
|
13
|
+
gem install fakeimage
|
|
14
|
+
fakeimage --port 5000 # arguments are forwarded to `rackup`
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### Directly from the Source Repo
|
|
18
|
+
```bash
|
|
19
|
+
git clone git@github.com:xxx/fakeimage.git
|
|
20
|
+
cd fakeimage
|
|
21
|
+
bundle
|
|
22
|
+
ruby fakeimage.rb (or your rack-app-handler of choice)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A `Dockerfile` and `docker-compose.yml` are included in the distribution if preferred. Getting up and running
|
|
26
|
+
locally should require nothing more than `docker compose up` in that case.
|
|
27
|
+
|
|
28
|
+
## Use
|
|
29
|
+
|
|
30
|
+
In a browser, hit `http://localhost:4567/300x200` for example, or change bg and text colors by passing them as
|
|
31
|
+
GET params:
|
|
32
|
+
|
|
33
|
+
`http://localhost:4567/95x150?color=red&textcolor=orange`
|
|
34
|
+
|
|
35
|
+
Leave off the second dimension for a square.
|
|
36
|
+
|
|
37
|
+
`http://localhost:4567/200`
|
|
38
|
+
|
|
39
|
+
Multiple image formats are supported. Just add an extension to the size (e.g. `http://localhost:4567/300x200.gif`) to
|
|
40
|
+
get that format. png (default), gif, and jpg are supported currently.
|
|
41
|
+
|
|
42
|
+
See [the ImageMagick documentation](http://www.imagemagick.org/script/color.php#color_names) for the canonical list
|
|
43
|
+
of colors. Hex colors are also supported, but with the `#` replaced with a `!`,
|
|
44
|
+
like `http://localhost:4567/400x300?color=!849593`.
|
|
45
|
+
|
|
46
|
+
## Copyright
|
|
47
|
+
|
|
48
|
+
Copyright (c) Michael Dungan <mpd@jesters-court.net>, released under the MIT license.
|
|
49
|
+
|
|
50
|
+
The included Droid Sans font is licensed under the Apache License, online at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
data/bin/fakeimage
ADDED
data/config.ru
ADDED
data/docker-compose.yml
ADDED
data/fakeimage.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'logger'
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'bundler/setup'
|
|
6
|
+
|
|
7
|
+
require 'sinatra'
|
|
8
|
+
require 'rmagick'
|
|
9
|
+
require 'rvg/rvg'
|
|
10
|
+
|
|
11
|
+
FORMATS = {
|
|
12
|
+
'png' => 'png',
|
|
13
|
+
'gif' => 'gif',
|
|
14
|
+
'jpg' => 'jpeg'
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
LOGGER = Logger.new($stdout)
|
|
18
|
+
|
|
19
|
+
get '/' do
|
|
20
|
+
<<~HTML
|
|
21
|
+
<p>Welcome to fakeimage.</p>
|
|
22
|
+
<p>
|
|
23
|
+
Please see the README (specifically the 'Use' section) at
|
|
24
|
+
<a href='http://github.com/xxx/fakeimage'>http://github.com/xxx/fakeimage</a> for#{' '}
|
|
25
|
+
usage info so I don't have a chance to let one of the copies get out of date.
|
|
26
|
+
</p>
|
|
27
|
+
<p>Example: <img src='/243x350.gif?color=darkorchid2&textcolor=!B9AF55' /></p>
|
|
28
|
+
<p>
|
|
29
|
+
Code:#{' '}
|
|
30
|
+
<code><img src='http://fakeimage.heroku.com/243x350.gif?color=darkorchid2&textcolor=!B9AF55' /></code>
|
|
31
|
+
</p>
|
|
32
|
+
HTML
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
get '/:size' do
|
|
36
|
+
wh, format = params[:size].downcase.split('.')
|
|
37
|
+
format = FORMATS[format] || 'png'
|
|
38
|
+
|
|
39
|
+
width, height = wh.split('x').map(&:to_i)
|
|
40
|
+
|
|
41
|
+
height ||= width
|
|
42
|
+
|
|
43
|
+
color = color_convert(params[:color]) || 'grey69'
|
|
44
|
+
text_color = color_convert(params[:textcolor]) || 'black'
|
|
45
|
+
|
|
46
|
+
rvg = Magick::RVG.new(width, height).viewbox(0, 0, width, height) do |canvas|
|
|
47
|
+
canvas.background_fill = color
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
img = rvg.draw
|
|
51
|
+
|
|
52
|
+
img.format = format
|
|
53
|
+
|
|
54
|
+
drawable = Magick::Draw.new
|
|
55
|
+
drawable.pointsize = width / 10
|
|
56
|
+
drawable.font = './DroidSans.ttf'
|
|
57
|
+
drawable.fill = text_color
|
|
58
|
+
drawable.gravity = Magick::CenterGravity
|
|
59
|
+
drawable.annotate(img, 0, 0, 0, 0, "#{width} x #{height}")
|
|
60
|
+
|
|
61
|
+
content_type "image/#{format}"
|
|
62
|
+
img.to_blob
|
|
63
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
64
|
+
LOGGER.error("#{e}: #{e.backtrace}")
|
|
65
|
+
<<~HTML
|
|
66
|
+
<p>
|
|
67
|
+
Something broke. You can try <a href='/200x200'>this simple test</a>.#{' '}
|
|
68
|
+
If this error occurs there as well, you are probably missing app dependencies. Make sure RMagick#{' '}
|
|
69
|
+
is installed correctly. If the test works, you are probably passing bad params in the url.
|
|
70
|
+
</p>
|
|
71
|
+
<p>Use this thing like http://host:port/200x300, or add color and textcolor params to decide color.</p>
|
|
72
|
+
<p>Error is: [<code>#{e}</code>]</p>
|
|
73
|
+
HTML
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
def color_convert(original)
|
|
79
|
+
original&.tr('!', '#')
|
|
80
|
+
end
|
data/public/favicon.ico
ADDED
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fakeimage
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.9'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Michael Dungan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: puma
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rmagick
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: sinatra
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: pry
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop-performance
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rubocop-rake
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
description: This gem providers a small server to allow linking to arbitrarily-sized
|
|
112
|
+
placeholder images.
|
|
113
|
+
email:
|
|
114
|
+
- mpd@jesters-court.net
|
|
115
|
+
executables:
|
|
116
|
+
- fakeimage
|
|
117
|
+
extensions: []
|
|
118
|
+
extra_rdoc_files: []
|
|
119
|
+
files:
|
|
120
|
+
- ".rubocop.yml"
|
|
121
|
+
- ".ruby-version"
|
|
122
|
+
- Dockerfile
|
|
123
|
+
- DroidSans.ttf
|
|
124
|
+
- Gemfile
|
|
125
|
+
- Gemfile.lock
|
|
126
|
+
- Procfile
|
|
127
|
+
- README.md
|
|
128
|
+
- bin/fakeimage
|
|
129
|
+
- config.ru
|
|
130
|
+
- docker-compose.yml
|
|
131
|
+
- fakeimage.rb
|
|
132
|
+
- public/favicon.ico
|
|
133
|
+
homepage: https://github.com/xxx/fakeimage
|
|
134
|
+
licenses:
|
|
135
|
+
- MIT
|
|
136
|
+
metadata:
|
|
137
|
+
homepage_uri: https://github.com/xxx/fakeimage
|
|
138
|
+
source_code_uri: https://github.com/xxx/fakeimage
|
|
139
|
+
rubygems_mfa_required: 'true'
|
|
140
|
+
post_install_message:
|
|
141
|
+
rdoc_options: []
|
|
142
|
+
require_paths:
|
|
143
|
+
- lib
|
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: 2.7.0
|
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
|
+
requirements:
|
|
151
|
+
- - ">="
|
|
152
|
+
- !ruby/object:Gem::Version
|
|
153
|
+
version: '0'
|
|
154
|
+
requirements: []
|
|
155
|
+
rubygems_version: 3.3.7
|
|
156
|
+
signing_key:
|
|
157
|
+
specification_version: 4
|
|
158
|
+
summary: A placeholder image generator
|
|
159
|
+
test_files: []
|