catscope 0.0.1 → 0.0.2
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 +4 -4
- data/lib/catscope/app.rb +27 -2
- data/lib/catscope/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a04352dbd5d2bc81dbceed21903c1bd5e0096e5c
|
4
|
+
data.tar.gz: 01e87cf27af948d71f8a440e03785c90959934dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b1b3b97e558c044a43feab5d1f2f9e453352dd8b4c3119fd526e23ce7ee520ad21d6799acb5aa7a0a97290b4f29b6c9d853e58c978f291f02c312b624fc973c
|
7
|
+
data.tar.gz: 05dd7cf692a3331a8a23d7a7533106c303385505bc5b9572f60b108eda72b7265b04c33ffca3c9c1e0137e4b02984a9a5ac07f4c04d11955a4ad4db94154f600
|
data/lib/catscope/app.rb
CHANGED
@@ -9,7 +9,9 @@ require 'json'
|
|
9
9
|
module Catscope
|
10
10
|
|
11
11
|
class App < Sinatra::Base
|
12
|
+
EPS_MIN_PIXELS = 1024*1024 / 2
|
12
13
|
TOP_DIR = Pathname.new(Dir.pwd).realpath
|
14
|
+
|
13
15
|
register Sinatra::AssetPack
|
14
16
|
register Sinatra::RocketIO
|
15
17
|
|
@@ -60,6 +62,18 @@ class App < Sinatra::Base
|
|
60
62
|
return "text/plain"
|
61
63
|
end
|
62
64
|
end
|
65
|
+
|
66
|
+
def image_size(file_path)
|
67
|
+
unless system("which identify >/dev/null 2>&1")
|
68
|
+
return nil
|
69
|
+
end
|
70
|
+
|
71
|
+
identify_str = `identify "#{file_path}"`
|
72
|
+
unless identify_str =~ /\s(\d+)x(\d+)\s/
|
73
|
+
return nil
|
74
|
+
end
|
75
|
+
[$~[1].to_i, $~[2].to_i]
|
76
|
+
end
|
63
77
|
end
|
64
78
|
|
65
79
|
io = Sinatra::RocketIO
|
@@ -128,8 +142,19 @@ class App < Sinatra::Base
|
|
128
142
|
content_type type_by_path(path)
|
129
143
|
|
130
144
|
if path =~ /\.(eps|svg)$/
|
131
|
-
|
132
|
-
|
145
|
+
imgsize = image_size(path)
|
146
|
+
|
147
|
+
p imgsize
|
148
|
+
|
149
|
+
resize_option = ""
|
150
|
+
if imgsize && imgsize[0]*imgsize[1] < EPS_MIN_PIXELS
|
151
|
+
dpi = (72 * ((EPS_MIN_PIXELS / (imgsize[0]*imgsize[1]).to_f)) ** 0.5).to_i
|
152
|
+
resize_option = "-density #{dpi}"
|
153
|
+
end
|
154
|
+
|
155
|
+
convert_cmd = "convert #{resize_option} \"#{path}\" png:-"
|
156
|
+
out = IO.popen(convert_cmd)
|
157
|
+
puts(convert_cmd)
|
133
158
|
else
|
134
159
|
out = File.open(path)
|
135
160
|
end
|
data/lib/catscope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuto Hayamizu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thin
|