libjpeg-ruby 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca94a8b3e9236b03b8ec0ca9f9b30837a6f3cb0c7014f9e48b169601a701fc44
4
- data.tar.gz: cefa3b898236cc01e540ca6003cfa6792c39acf4b5793bf438dd47b6f8c23b75
3
+ metadata.gz: 29398bd546766eb9b4c660c7e9b71910debbfc065e2a6e66377b4448cd73d7ae
4
+ data.tar.gz: 4e1e5521b1c2ad8dd45b47bca048eb446e72ef7d76a84e97ea36929a9cbbbddb
5
5
  SHA512:
6
- metadata.gz: f3b89c866bdc6fbe311d40b221e67c718068f9920e1db3b33a728478a79910808ce0b25f1a81628d7590d2f907d57572ddd91068b3e07330c562d34cab66e5be
7
- data.tar.gz: b41ac45a2640e54bf341a8bb684d7740c8d17cdf25bdbeb1bce369bbc9d4a13dd29c570486cbbf72ea6ff5300fdfe0ba237ce1a6175a6d5da02c39b582a65d9c
6
+ metadata.gz: a8140f6bf923073df861bf86d70c37e45360c8b34af33b5bab448e4564d3184b438597689d5276bc5d4a7956caef05d33d3525495e7fe6a136ab3d74c7024a14
7
+ data.tar.gz: 84efbe3208cb7ce49afd0000fe8814944f7c81fb19c490567436f201953a61a7f3f0245c18c11d8b7ec2d8b7bd3edd53ba181ecbc4b98a5e8155d7003979dcab
data/README.md CHANGED
@@ -1,2 +1,74 @@
1
1
  # libjpeg-ruby
2
2
  libjpeg interface for ruby.
3
+
4
+ ## Installation
5
+
6
+ ```ruby
7
+ gem 'libjpeg-ruby'
8
+ ```
9
+
10
+ And then execute:
11
+
12
+ $ bundle
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install libjpeg-ruby
17
+
18
+ ## Usage
19
+
20
+ ### decode sample
21
+
22
+ ```ruby
23
+ require 'jpeg'
24
+
25
+ dec = JPEG::Decoder.new(:pixel_format => :BGR)
26
+
27
+ p dec.read_header(IO.binread("test.jpg")
28
+
29
+ raw = dec << IO.binread("test.jpg")
30
+ p raw.meta
31
+
32
+ IO.binwrite("test.bgr", raw)
33
+ ```
34
+
35
+ #### decode options
36
+ | option | value type | description |
37
+ |---|---|---|
38
+ | :pixel_format | String or Symbol | output format |
39
+ | :output_gamma | Float | gamma value |
40
+ | :fancy_upsampling | Boolean | T.B.D |
41
+ | :do_smoothing | Boolean | T.B.D |
42
+ | :opt_dither | [{str}MODE, {bool}2PASS, {int}NUM_COLORS] | T.B.D |
43
+ | :use_1ass_quantizer | Boolean | T.B.D |
44
+ | :use_external_colormap | Boolean | T.B.D |
45
+ | :use_2pass_quantizer | Boolean | T.B.D |
46
+ | :without_meta | Boolean | T.B.D |
47
+ | :expand_colormap | Booblean | T.B.D |
48
+ | :scale | Rational or Float | T.B.D |
49
+ | :dct_method | String or Symbol | T.B.D |
50
+
51
+ #### supported output format
52
+ RGB RGB24 YUV422 YUYV RGB565 YUV444 YCbCr BGR BGR24 RGBX RGB32 BGRX BGR32
53
+
54
+ #### supported DCT method
55
+ ISLOW IFAST FLOAT FASTEST
56
+
57
+ ### encode sample
58
+
59
+ ```ruby
60
+ require 'jpeg'
61
+
62
+ enc = JPEG::Encoder.new(640, 480, :pixel_format => :YCbCr)
63
+
64
+ IO.binwrite("test.jpg", enc << IO.binread("test.raw"))
65
+ ```
66
+ #### encode option
67
+ #### encode options
68
+ | option | value type | description |
69
+ |---|---|---|
70
+ | :pixel_fromat | String or Symbol | input format |
71
+ | :quality | Integer | encode quality (0-100) |
72
+ | :scale | Rational or Float | |
73
+ | :dct_method | String or Symbol | T.B.D |
74
+
data/ext/jpeg/jpeg.c CHANGED
@@ -82,6 +82,7 @@ static const char* encoder_opts_keys[] = {
82
82
  "pixel_format", // {str}
83
83
  "quality", // {integer}
84
84
  "scale", // {rational} or {float}
85
+ "dct_method" // {str}
85
86
  };
86
87
 
87
88
  static ID encoder_opts_ids[N(encoder_opts_keys)];
@@ -92,6 +93,7 @@ typedef struct {
92
93
  int height;
93
94
 
94
95
  int data_size;
96
+ J_DCT_METHOD dct_method;
95
97
 
96
98
  struct jpeg_compress_struct cinfo;
97
99
  struct jpeg_error_mgr jerr;
@@ -112,6 +114,7 @@ static const char* decoder_opts_keys[] = {
112
114
  "without_meta", // {bool}
113
115
  "expand_colormap", // {bool}
114
116
  "scale", // {rational} or {float}
117
+ "dct_method" // {str}
115
118
  };
116
119
 
117
120
  static ID decoder_opts_ids[N(decoder_opts_keys)];
@@ -138,6 +141,7 @@ typedef struct {
138
141
  boolean do_block_smoothing;
139
142
  boolean quantize_colors;
140
143
  J_DITHER_MODE dither_mode;
144
+ J_DCT_METHOD dct_method;
141
145
  boolean two_pass_quantize;
142
146
  int desired_number_of_colors;
143
147
  boolean enable_1pass_quant;
@@ -191,6 +195,8 @@ rb_encoder_alloc(VALUE self)
191
195
  ptr = ALLOC(jpeg_encode_t);
192
196
  memset(ptr, 0, sizeof(*ptr));
193
197
 
198
+ ptr->dct_method = JDCT_FASTEST;
199
+
194
200
  return Data_Wrap_Struct(encoder_klass, 0, rb_encoder_free, ptr);
195
201
  }
196
202
 
@@ -314,6 +320,24 @@ set_encoder_context(jpeg_encode_t* ptr, int wd, int ht, VALUE opt)
314
320
  break;
315
321
  }
316
322
 
323
+ /*
324
+ * eval dct_method option
325
+ */
326
+ if (opts[3] == Qundef || EQ_STR(opts[3], "FASTEST")) {
327
+ ptr->dct_method = JDCT_FASTEST;
328
+
329
+ } else if (EQ_STR(opts[3], "ISLOW")) {
330
+ ptr->dct_method = JDCT_ISLOW;
331
+
332
+ } else if (EQ_STR(opts[3], "IFAST")) {
333
+ ptr->dct_method = JDCT_IFAST;
334
+
335
+ } else if (EQ_STR(opts[3], "FLOAT")) {
336
+ ptr->dct_method = JDCT_FLOAT;
337
+
338
+ } else {
339
+ ARGUMENT_ERROR("Unsupportd :dct_method option value.");
340
+ }
317
341
 
318
342
  /*
319
343
  * set context
@@ -343,7 +367,7 @@ set_encoder_context(jpeg_encode_t* ptr, int wd, int ht, VALUE opt)
343
367
  ptr->cinfo.optimize_coding = TRUE;
344
368
  ptr->cinfo.arith_code = TRUE;
345
369
  ptr->cinfo.raw_data_in = FALSE;
346
- ptr->cinfo.dct_method = JDCT_FASTEST;
370
+ ptr->cinfo.dct_method = ptr->dct_method;
347
371
 
348
372
  jpeg_set_defaults(&ptr->cinfo);
349
373
  jpeg_set_quality(&ptr->cinfo, quality, TRUE);
@@ -642,6 +666,7 @@ rb_decoder_alloc(VALUE self)
642
666
  ptr->do_block_smoothing = FALSE;
643
667
  ptr->quantize_colors = FALSE;
644
668
  ptr->dither_mode = JDITHER_NONE;
669
+ ptr->dct_method = JDCT_FASTEST;
645
670
  ptr->desired_number_of_colors = 0;
646
671
  ptr->enable_1pass_quant = FALSE;
647
672
  ptr->enable_external_quant = FALSE;
@@ -969,6 +994,28 @@ eval_decoder_opt_scale(jpeg_decode_t* ptr, VALUE opt)
969
994
  }
970
995
  }
971
996
 
997
+ static void
998
+ eval_decoder_opt_dct_method(jpeg_decode_t* ptr, VALUE opt)
999
+ {
1000
+ if (opt != Qundef) {
1001
+ if (EQ_STR(opt, "ISLOW")) {
1002
+ ptr->dct_method = JDCT_ISLOW;
1003
+
1004
+ } else if (EQ_STR(opt, "IFAST")) {
1005
+ ptr->dct_method = JDCT_IFAST;
1006
+
1007
+ } else if (EQ_STR(opt, "FLOAT")) {
1008
+ ptr->dct_method = JDCT_FLOAT;
1009
+
1010
+ } else if (EQ_STR(opt, "FASTEST")) {
1011
+ ptr->dct_method = JDCT_FASTEST;
1012
+
1013
+ } else {
1014
+ ARGUMENT_ERROR("Unsupportd :dct_method option value.");
1015
+ }
1016
+ }
1017
+ }
1018
+
972
1019
  static void
973
1020
  set_decoder_context( jpeg_decode_t* ptr, VALUE opt)
974
1021
  {
@@ -990,11 +1037,10 @@ set_decoder_context( jpeg_decode_t* ptr, VALUE opt)
990
1037
  eval_decoder_opt_use_1pass_quantizer(ptr, opts[5]);
991
1038
  eval_decoder_opt_use_external_colormap(ptr, opts[6]);
992
1039
  eval_decoder_opt_use_2pass_quantizer(ptr, opts[7]);
993
-
994
1040
  eval_decoder_opt_without_meta(ptr, opts[8]);
995
1041
  eval_decoder_opt_expand_colormap(ptr, opts[9]);
996
-
997
1042
  eval_decoder_opt_scale(ptr, opts[10]);
1043
+ eval_decoder_opt_dct_method(ptr, opts[11]);
998
1044
  }
999
1045
 
1000
1046
  static VALUE
@@ -1336,7 +1382,7 @@ do_decode(jpeg_decode_t* ptr, uint8_t* jpg, size_t jpg_sz)
1336
1382
  jpeg_read_header(cinfo, TRUE);
1337
1383
 
1338
1384
  cinfo->raw_data_out = FALSE;
1339
- cinfo->dct_method = JDCT_FLOAT;
1385
+ cinfo->dct_method = ptr->dct_method;
1340
1386
 
1341
1387
  cinfo->out_color_space = ptr->out_color_space;
1342
1388
  cinfo->out_color_components = ptr->out_color_components;
data/lib/jpeg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JPEG
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
data/libjpeg-ruby.gemspec CHANGED
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.extensions = ["ext/jpeg/extconf.rb"]
32
32
  spec.require_paths = ["lib"]
33
33
 
34
+ spec.required_ruby_version = ">= 2.4.0"
35
+
34
36
  spec.add_development_dependency "bundler", "~> 1.17"
35
37
  spec.add_development_dependency "rake", "~> 10.0"
36
38
  spec.add_development_dependency "rake-compiler"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libjpeg-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Kuwagata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-16 00:00:00.000000000 Z
11
+ date: 2019-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ">="
83
83
  - !ruby/object:Gem::Version
84
- version: '0'
84
+ version: 2.4.0
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="