ImageResize 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ === 0.0.4 2010-06-28
2
+ * show Image formats
3
+
1
4
  === 0.0.3 2010-06-28
2
5
  * get image format from filename
3
6
 
@@ -14,6 +14,11 @@ Simple image resize library without external program.
14
14
  # input_image_filename, output_image_filename, max_width, max_height
15
15
  Image.resize('big.jpg', 'small.jpg', 40, 40)
16
16
 
17
+ # show formats
18
+ p Image.formats
19
+ p Image.read_formats
20
+ p Image.write_formats
21
+
17
22
  == REQUIREMENTS:
18
23
 
19
24
  * Java 1.5 or higher
Binary file
Binary file
@@ -4,5 +4,5 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'ImageResize/Image'
5
5
 
6
6
  module ImageResize
7
- VERSION = '0.0.3'
7
+ VERSION = '0.0.4'
8
8
  end
@@ -1,11 +1,43 @@
1
1
  module Image
2
+
3
+ $VERBOSE = nil
2
4
 
3
- def Image.resize(img_in, img_out, width, height)
5
+ def Image.cmd
4
6
  jar_path = File.expand_path(File.dirname(__FILE__)).split(/\//)
5
7
  jar_path.pop
6
8
  jar_path.pop
7
9
  resizer = "#{jar_path.join('/')}/java/ImageResize.jar"
8
- puts `java -jar #{resizer} #{img_in} #{img_out} #{width} #{height}`
10
+ "java -jar #{resizer}"
11
+ end
12
+
13
+ def Image.resize(img_in, img_out, width, height)
14
+ puts `#{Image.cmd} resize #{img_in} #{img_out} #{width} #{height}`
15
+ end
16
+
17
+ def Image.formats
18
+ lines = `#{Image.cmd} formats`
19
+ read_formats = nil
20
+ write_formats = nil
21
+ for line in lines.split(/[\r\n]/) do
22
+ rw, format = line.split(/\:/)
23
+ formats = format.split(/,/).map{|f|f.downcase}.uniq.sort
24
+ if rw == 'read'
25
+ read_formats = formats
26
+ elsif rw == 'write'
27
+ write_formats = formats
28
+ end
29
+ end
30
+ return read_formats, write_formats
31
+ end
32
+
33
+ def Image.read_formats
34
+ r,w = Image.formats
35
+ r
36
+ end
37
+
38
+ def Image.write_formats
39
+ r,w = Image.formats
40
+ w
9
41
  end
10
42
 
11
43
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ImageResize
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sho Hashimoto