Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
C:¥Users¥**¥Documents¥code¥Ruby>ruby convert.rb
無効なパラメーターです - b.bmp
converted
convert.rb: [BUG] Segmentation fault
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32]
-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0002 E:00042c TOP [FINISH]
-- C level backtrace information -------------------------------------------
C:¥Windows¥SYSTEM32¥ntdll.dll(ZwWaitForSingleObject+0xc) [0x77CEC27C]
C:¥Windows¥SYSTEM32¥KERNELBASE.dll(WaitForSingleObject+0x12) [0x77222C02]
C:¥Ruby22¥bin¥msvcrt-ruby220.dll(rb_vm_bugreport+0xa7) [0x640D4397]
C:¥Ruby22¥bin¥msvcrt-ruby220.dll(rb_bug_context+0x42) [0x63F86A72]
C:¥Ruby22¥bin¥msvcrt-ruby220.dll(rb_check_safe_obj+0x394) [0x6404F524]
[0x00401866]
C:¥Windows¥SYSTEM32¥ntdll.dll(LdrSetAppCompatDllRedirectionCallback+0x13444) [0x
77D5F154]
-- Other runtime information -----------------------------------------------
* Loaded script: convert.rb
* Loaded features:
0 enumerator.so
1 rational.so
2 complex.so
3 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/enc/encdb.so
4 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/enc/trans/transdb.so
5 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/enc/windows_31j.so
6 C:/Ruby22/lib/ruby/2.2.0/unicode_normalize.rb
7 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/rbconfig.rb
8 thread.rb
9 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/thread.so
10 C:/Ruby22/lib/ruby/2.2.0/rubygems/compatibility.rb
11 C:/Ruby22/lib/ruby/2.2.0/rubygems/defaults.rb
12 C:/Ruby22/lib/ruby/2.2.0/rubygems/deprecate.rb
13 C:/Ruby22/lib/ruby/2.2.0/rubygems/errors.rb
14 C:/Ruby22/lib/ruby/2.2.0/rubygems/version.rb
15 C:/Ruby22/lib/ruby/2.2.0/rubygems/requirement.rb
16 C:/Ruby22/lib/ruby/2.2.0/rubygems/platform.rb
17 C:/Ruby22/lib/ruby/2.2.0/rubygems/basic_specification.rb
18 C:/Ruby22/lib/ruby/2.2.0/rubygems/stub_specification.rb
19 C:/Ruby22/lib/ruby/2.2.0/rubygems/util/stringio.rb
20 C:/Ruby22/lib/ruby/2.2.0/rubygems/specification.rb
21 C:/Ruby22/lib/ruby/2.2.0/rubygems/exceptions.rb
22 C:/Ruby22/lib/ruby/2.2.0/rubygems/defaults/operating_system.rb
23 C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb
24 C:/Ruby22/lib/ruby/2.2.0/monitor.rb
25 C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
26 C:/Ruby22/lib/ruby/2.2.0/rubygems.rb
27 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/enc/shift_jis.so
28 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/enc/trans/japanese_sjis.so
29 C:/Ruby22/lib/ruby/2.2.0/rubygems/path_support.rb
30 C:/Ruby22/lib/ruby/2.2.0/rubygems/dependency.rb
31 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/etc.so
32 C:/Ruby22/lib/ruby/2.2.0/fileutils.rb
33 C:/Ruby22/lib/ruby/2.2.0/tmpdir.rb
34 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/pathname.so
35 C:/Ruby22/lib/ruby/2.2.0/pathname.rb
36 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/colo
r.rb
37 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/pape
r.rb
38 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/2.2/cairo.
so
39 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cons
tants.rb
40 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/poin
t.rb
41 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/colo
rs.rb
42 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/pape
rs.rb
43 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext/rectangle.rb
44 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext/triangle.rb
45 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext/circle.rb
46 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext/path.rb
47 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext/blur.rb
48 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext/color.rb
49 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/cont
ext.rb
50 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/devi
ce.rb
51 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/surf
ace.rb
52 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/patt
ern.rb
53 C:/Ruby22/lib/ruby/2.2.0/forwardable.rb
54 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/path
.rb
55 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo/regi
on.rb
56 C:/Ruby22/lib/ruby/gems/2.2.0/gems/cairo-1.15.2-x86-mingw32/lib/cairo.rb
57 C:/Ruby22/lib/ruby/2.2.0/English.rb
58 C:/Ruby22/lib/ruby/gems/2.2.0/gems/glib2-3.0.8-x86-mingw32/lib/glib2/depre
catable.rb
59 C:/Ruby22/lib/ruby/gems/2.2.0/gems/glib2-3.0.8-x86-mingw32/lib/2.2/glib2.s
o
60 C:/Ruby22/lib/ruby/gems/2.2.0/gems/glib2-3.0.8-x86-mingw32/lib/glib2/versi
on.rb
61 C:/Ruby22/lib/ruby/gems/2.2.0/gems/glib2-3.0.8-x86-mingw32/lib/glib2/regex
.rb
62 C:/Ruby22/lib/ruby/gems/2.2.0/gems/glib2-3.0.8-x86-mingw32/lib/glib2.rb
63 C:/Ruby22/lib/ruby/gems/2.2.0/gems/pango-3.0.8-x86-mingw32/lib/2.2/pango.s
o
64 C:/Ruby22/lib/ruby/gems/2.2.0/gems/pango-3.0.8-x86-mingw32/lib/pango.rb
65 C:/Ruby22/lib/ruby/gems/2.2.0/gems/gdk_pixbuf2-3.0.8-x86-mingw32/lib/2.2/g
dk_pixbuf2.so
66 C:/Ruby22/lib/ruby/gems/2.2.0/gems/gdk_pixbuf2-3.0.8-x86-mingw32/lib/gdk_p
ixbuf2.rb
67 C:/Ruby22/lib/ruby/gems/2.2.0/gems/atk-3.0.8-x86-mingw32/lib/2.2/atk.so
68 C:/Ruby22/lib/ruby/gems/2.2.0/gems/atk-3.0.8-x86-mingw32/lib/atk.rb
69 C:/Ruby22/lib/ruby/gems/2.2.0/gems/gtk2-3.0.8-x86-mingw32/lib/2.2/gtk2.so
70 C:/Ruby22/lib/ruby/gems/2.2.0/gems/gtk2-3.0.8-x86-mingw32/lib/gtk2/base.rb
71 C:/Ruby22/lib/ruby/gems/2.2.0/gems/gtk2-3.0.8-x86-mingw32/lib/gtk2.rb
72 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/ruby.rb
73 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/helper_me
thods.rb
74 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/colors.rb
75 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/basic.rb
76 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/main.rb
77 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/app.rb
78 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/anim.rb
79 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/slot.rb
80 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/text.rb
81 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/mask.rb
82 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/widget.rb
83 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/url.rb
84 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/style.rb
85 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/projector
.rb
86 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/download.
rb
87 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/manual.rb
88 C:/Ruby22/lib/ruby/2.2.0/find.rb
89 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/minitar.r
b
90 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/digest.so
91 C:/Ruby22/lib/ruby/2.2.0/digest.rb
92 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/digest/md5.so
93 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/zlib.so
94 C:/Ruby22/lib/ruby/2.2.0/psych/exception.rb
95 C:/Ruby22/lib/ruby/2.2.0/psych/syntax_error.rb
96 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/psych.so
97 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/stringio.so
98 C:/Ruby22/lib/ruby/2.2.0/psych/omap.rb
99 C:/Ruby22/lib/ruby/2.2.0/psych/set.rb
100 C:/Ruby22/lib/ruby/2.2.0/psych/class_loader.rb
101 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/strscan.so
102 C:/Ruby22/lib/ruby/2.2.0/psych/scalar_scanner.rb
103 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/node.rb
104 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/stream.rb
105 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/document.rb
106 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/sequence.rb
107 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/scalar.rb
108 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/mapping.rb
109 C:/Ruby22/lib/ruby/2.2.0/psych/nodes/alias.rb
110 C:/Ruby22/lib/ruby/2.2.0/psych/nodes.rb
111 C:/Ruby22/lib/ruby/2.2.0/psych/streaming.rb
112 C:/Ruby22/lib/ruby/2.2.0/psych/visitors/visitor.rb
113 C:/Ruby22/lib/ruby/2.2.0/psych/visitors/to_ruby.rb
114 C:/Ruby22/lib/ruby/2.2.0/psych/visitors/emitter.rb
115 C:/Ruby22/lib/ruby/2.2.0/psych/handler.rb
116 C:/Ruby22/lib/ruby/2.2.0/psych/tree_builder.rb
117 C:/Ruby22/lib/ruby/2.2.0/psych/visitors/yaml_tree.rb
118 C:/Ruby22/lib/ruby/2.2.0/psych/json/ruby_events.rb
119 C:/Ruby22/lib/ruby/2.2.0/psych/visitors/json_tree.rb
120 C:/Ruby22/lib/ruby/2.2.0/psych/visitors/depth_first.rb
121 C:/Ruby22/lib/ruby/2.2.0/psych/visitors.rb
122 C:/Ruby22/lib/ruby/2.2.0/psych/parser.rb
123 C:/Ruby22/lib/ruby/2.2.0/psych/coder.rb
124 C:/Ruby22/lib/ruby/2.2.0/psych/core_ext.rb
125 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/date_core.so
126 C:/Ruby22/lib/ruby/2.2.0/date.rb
127 C:/Ruby22/lib/ruby/2.2.0/psych/deprecated.rb
128 C:/Ruby22/lib/ruby/2.2.0/psych/stream.rb
129 C:/Ruby22/lib/ruby/2.2.0/psych/json/yaml_events.rb
130 C:/Ruby22/lib/ruby/2.2.0/psych/json/tree_builder.rb
131 C:/Ruby22/lib/ruby/2.2.0/psych/json/stream.rb
132 C:/Ruby22/lib/ruby/2.2.0/psych/handlers/document_stream.rb
133 C:/Ruby22/lib/ruby/2.2.0/psych.rb
134 C:/Ruby22/lib/ruby/2.2.0/yaml.rb
135 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/shoes/shy.rb
136 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/plugins/systray
.rb
137 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/plugins/thread.
rb
138 C:/Ruby22/lib/ruby/2.2.0/i386-mingw32/socket.so
139 C:/Ruby22/lib/ruby/2.2.0/socket.rb
140 C:/Ruby22/lib/ruby/2.2.0/timeout.rb
141 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/plugins/httpd.r
b
142 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/plugins/treevie
w.rb
143 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/plugins/code_bo
x.rb
144 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/plugins/video.r
b
145 C:/Ruby22/lib/ruby/gems/2.2.0/gems/green_shoes-1.1.374/lib/green_shoes.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
==================================================================
convert.rb
==================================================================
# encoding: Shift_JIS
require 'green_shoes'
Sf = %w(png PNG jpg jpeg JPG JPEG gif GIF bmp BMP)
class String
def imgfile?
return false unless m = /¥.(.+)$/.match(self)
return m[1] if Sf.include?(m[1])
false
end
def imgsuffix
Sf.each do |sf|
a = "." + sf
return a if include?(a)
end
""
end
end
Shoes.app width: 500, height: 480 do
background lavender
title "画像変換".encode("utf-8")
fname1 = fname2 = ""
stack height: 120 do
background azure
b = button "変換されるファイルを選択".encode("utf-8") do
fname1 = ask_open_file
end
a = para ""
b.click {a.clear; a = para fname1}
end
para "変換先のファイル名".encode("utf-8")
edit_line(width: 300) {|e| fname2 = e.text}
button "変換".encode("utf-8") do
if fname1.imgfile? and fname2.imgfile?
Dir.chdir(File.dirname(fname1))
`convert #{fname1} #{fname2}`
puts "converted"
exit
end
end
fname3 = ""
sf1 = sf2 = ""
para "¥n"
stack height: 120 do
background moccasin
para "一括変換するフォルダ".encode("utf-8")
b1 = button "選択".encode("utf-8") do
fname3 = ask_open_folder
end
a2 = para ""
b1.click {a2.clear; a2 = para fname3}
end
para "画像形式を選択して下さい(変換前/変換後)".encode("utf-8")
list_box items: ["jpg", "png", "bmp", "gif"] {|t| sf1 = t.text}
list_box items: ["jpg", "png", "bmp", "gif"] {|t| sf2 = t.text}
button "変換" do
if sf1 != sf2
Dir.chdir(fname3)
unless File.exist?("converted") and File.directory?("converted")
Dir.mkdir("converted")
end
Dir.chdir(fname3)
Dir.glob("*").each do |fn1|
a = fn1.imgsuffix.downcase
a = ".jpg" if a == ".jpeg"
if File.file?(fn1) and a == "." + sf1
fn2 = /(.+)¥..+$/.match(fn1)[1] + "." + sf2
`convert #{fn1} ./converted/#{fn2}`
end
end
puts "converted"
exit
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.