webp-ffi 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7745e9bcd09baff6c5ffe977eaf00e2ff078a628
4
- data.tar.gz: b948b1fa7ac70829b4ec1a95a19072aec525165f
3
+ metadata.gz: 2369fa3ab99b3d494db9eeeb7f19c340c940d91d
4
+ data.tar.gz: 58ebaf382e3b9159ccb01f9d780b76a9be55d11f
5
5
  SHA512:
6
- metadata.gz: 249cff2c45f5e988acedff8bd63226f8ad3ab845e97919281a4774b608ae17c16ba5451b3f8702de1bac5554c7bdfaf32ab82e69839ed92f96cb32a4223a1702
7
- data.tar.gz: 17e4db3fd151581ade623b92d406f0c4477d4c0980255897ea8e9be660bad97562f8fa6952e2937e42029d58f03c0f79c11d559adf4666cbc02f3f95d29932c9
6
+ metadata.gz: feb10c1edaaab6101c969dc8ea38324dae4e9a5268d71f994abb8dff878b1ce2c54553a19100bbf982d5b59ad99c6f692c974b3a5345fa03fae369dd067d4794
7
+ data.tar.gz: 002dda47a905f3f2e2dfd85b310eacd7771df366eeb663c0754ba10a9b54f3fb351768b46b8195799ea1b07da670c2a1a45a343030774bb80b80c9727410c5cc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.2.2
2
+
3
+ * Fix png lossless
4
+
1
5
  ## v0.2.1
2
6
 
3
7
  * Fix output for bmp, tiff and yuv
data/README.md CHANGED
@@ -116,13 +116,16 @@ Decode webp image (default format is png):
116
116
  WebP.decode(filename, out_filename)
117
117
 
118
118
 
119
- Decode webp image to pam, ppm or pgm format of image:
119
+ Decode webp image to pam, ppm, pgm, bmp, tiff or yuv format of image:
120
120
 
121
121
  filename = File.expand_path(File.join(File.dirname(__FILE__), "spec/factories/4.webp"))
122
122
  out_filename = File.expand_path(File.join(File.dirname(__FILE__), "tmp/4.png"))
123
123
  WebP.decode(filename, out_filename, output_format: :pam)
124
124
  WebP.decode(filename, out_filename, output_format: :ppm)
125
125
  WebP.decode(filename, out_filename, output_format: :pgm)
126
+ WebP.decode(filename, out_filename, output_format: :bmp)
127
+ WebP.decode(filename, out_filename, output_format: :tiff)
128
+ WebP.decode(filename, out_filename, output_format: :yuv)
126
129
 
127
130
 
128
131
  Decode webp image with options:
data/ext/webp_ffi/util.c CHANGED
@@ -137,7 +137,8 @@ static void PNGAPI error_function(png_structp png, png_const_charp dummy) {
137
137
 
138
138
  static int UtilReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha) {
139
139
  png_structp png;
140
- png_infop info;
140
+ png_infop info = NULL;
141
+ png_infop end_info = NULL;
141
142
  int color_type, bit_depth, interlaced;
142
143
  int has_alpha;
143
144
  int num_passes;
@@ -155,13 +156,14 @@ static int UtilReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha) {
155
156
  png_set_error_fn(png, 0, error_function, NULL);
156
157
  if (setjmp(png_jmpbuf(png))) {
157
158
  Error:
158
- png_destroy_read_struct(&png, NULL, NULL);
159
- free(rgb);
159
+ png_destroy_read_struct(&png, &info, &end_info);
160
160
  goto End;
161
161
  }
162
162
 
163
163
  info = png_create_info_struct(png);
164
164
  if (info == NULL) goto Error;
165
+ end_info = png_create_info_struct(png);
166
+ if (end_info == NULL) goto Error;
165
167
 
166
168
  png_init_io(png, in_file);
167
169
  png_read_info(png, info);
@@ -202,20 +204,21 @@ static int UtilReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha) {
202
204
  png_read_rows(png, &row, NULL, 1);
203
205
  }
204
206
  }
205
- png_read_end(png, info);
206
- png_destroy_read_struct(&png, &info, NULL);
207
+ png_read_end(png, end_info);
208
+ png_destroy_read_struct(&png, &info, &end_info);
207
209
 
208
210
  pic->width = width;
209
211
  pic->height = height;
212
+ pic->use_argb = 1;
210
213
  ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride)
211
214
  : WebPPictureImportRGB(pic, rgb, stride);
212
- free(rgb);
213
215
 
214
- if (ok && has_alpha && keep_alpha == 2) {
215
- WebPCleanupTransparentArea(pic);
216
+ if (!ok) {
217
+ goto Error;
216
218
  }
217
219
 
218
220
  End:
221
+ free(rgb);
219
222
  return ok;
220
223
  }
221
224
 
data/lib/webp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WebP
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webp-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vasyliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-17 00:00:00.000000000 Z
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi