jpeg 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Yamada Masaki
1
+ Copyright (c) 2012 masarakki
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -11,6 +11,9 @@ or
11
11
  jpeg = Jpeg.open('path/to/file')
12
12
  jpeg.size # => [1920, 1080]
13
13
 
14
+ == What can do
15
+ - get size
16
+
14
17
  == Contributing to jpeg
15
18
 
16
19
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
data/ext/jpeg_jpeg.c CHANGED
@@ -12,6 +12,7 @@ static void jpeg_jpeg_free(struct jpeg_jpeg *p);
12
12
  static VALUE jpeg_jpeg_width(VALUE self);
13
13
  static VALUE jpeg_jpeg_height(VALUE self);
14
14
  static VALUE jpeg_jpeg_size(VALUE self);
15
+ static VALUE jpeg_jpeg_color_info(VALUE self);
15
16
 
16
17
  extern VALUE Jpeg_Error;
17
18
 
@@ -22,7 +23,9 @@ void Init_jpeg_jpeg() {
22
23
  rb_define_method(Jpeg, "width", jpeg_jpeg_width, 0);
23
24
  rb_define_method(Jpeg, "height", jpeg_jpeg_height, 0);
24
25
  rb_define_method(Jpeg, "size", jpeg_jpeg_size, 0);
26
+ rb_define_method(Jpeg, "color_info", jpeg_jpeg_color_info, 0);
25
27
  }
28
+
26
29
  void jpeg_jpeg_exit(j_common_ptr jpeg) {
27
30
  char buffer[JMSG_LENGTH_MAX];
28
31
  jpeg->err->format_message(jpeg, buffer);
@@ -102,3 +105,10 @@ static VALUE jpeg_jpeg_size(VALUE self) {
102
105
 
103
106
  return array;
104
107
  }
108
+
109
+ static VALUE jpeg_jpeg_color_info(VALUE self) {
110
+ struct jpeg_jpeg *p_jpeg;
111
+
112
+ Data_Get_Struct(self, struct jpeg_jpeg, p_jpeg);
113
+ return ID2SYM(rb_intern( p_jpeg->read->out_color_components == 3 ? "rgb" : "gray" ));
114
+ }
data/jpeg.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "jpeg"
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["masarakki"]
12
- s.date = "2012-04-02"
12
+ s.date = "2012-04-07"
13
13
  s.description = "libjpeg wrapper for ruby"
14
14
  s.email = "masaki@hisme.net"
15
15
  s.extensions = ["ext/extconf.rb"]
data/lib/jpeg.rb CHANGED
@@ -10,4 +10,12 @@ class Jpeg
10
10
  tmp.close
11
11
  jpeg
12
12
  end
13
+
14
+ def rgb?
15
+ color_info == :rgb
16
+ end
17
+
18
+ def gray?
19
+ color_info == :gray
20
+ end
13
21
  end
data/spec/jpeg_spec.rb CHANGED
@@ -12,6 +12,9 @@ describe "Jpeg" do
12
12
  its(:size) { should == [112, 112] }
13
13
  its(:width) { should == 112 }
14
14
  its(:height) { should == 112 }
15
+ its(:color_info) { should == :rgb }
16
+ its(:rgb?) { should be_true }
17
+ its(:gray?) { should be_false }
15
18
  end
16
19
  context "non-exists file" do
17
20
  it {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpeg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000 Z
12
+ date: 2012-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: 677594223
123
+ hash: -1032745497266643110
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements: