pngdefry 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Rakefile +7 -0
- data/ext/pngdefry/pngdefry.c +8 -3
- data/lib/pngdefry.rb +11 -0
- data/lib/pngdefry/version.rb +1 -1
- data/test/data/40@2x.png +0 -0
- data/test/data/60@2x.png +0 -0
- data/test/pngdefry_test.rb +31 -0
- data/test/test_helper.rb +6 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1383481288a92a51651e5a7160f812d57f4458
|
4
|
+
data.tar.gz: 07585aa4c2d7c734105883e605cec887a2746263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f46e10295f030f12fd0ee20bd89948cc0dccdf2ea7d8ae225c297d1b523465aae12032a8f992b407cd66e5b6993d363f17cd33f8794b6e0796f21c4448c388f3
|
7
|
+
data.tar.gz: e92cf7ba0556099e1a572b7db08f60be251dd048bae9d9a9894d23dc4b7d06bded79e07d77ad222fe675825b19ac23ad12a5b0f829f264b1df060427b8df8088
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/extensiontask'
|
3
|
+
require 'rake/testtask'
|
3
4
|
|
4
5
|
spec = Gem::Specification.load('pngdefry.gemspec')
|
5
6
|
Rake::ExtensionTask.new('pngdefry', spec)
|
7
|
+
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.libs << 'test'
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
11
|
+
end
|
12
|
+
task default: [:compile, :test]
|
data/ext/pngdefry/pngdefry.c
CHANGED
@@ -390,6 +390,12 @@ void applyRowFilters (int wide, int high, unsigned char *data)
|
|
390
390
|
|
391
391
|
int process (char *filename, char *write_file_name, unsigned int *width, unsigned int *height)
|
392
392
|
{
|
393
|
+
// Reset
|
394
|
+
repack_IDAT_size = 524288;
|
395
|
+
num_chunks = 0;
|
396
|
+
max_chunks = 0;
|
397
|
+
pngChunks = NULL;
|
398
|
+
|
393
399
|
FILE *f;
|
394
400
|
unsigned int length;
|
395
401
|
int i;
|
@@ -1143,7 +1149,7 @@ int process (char *filename, char *write_file_name, unsigned int *width, unsigne
|
|
1143
1149
|
{
|
1144
1150
|
printf ("%s : ", filename);
|
1145
1151
|
}
|
1146
|
-
printf ("writing to file %s\n", write_file_name);
|
1152
|
+
//printf ("writing to file %s\n", write_file_name);
|
1147
1153
|
|
1148
1154
|
write_file = fopen (write_file_name, "wb");
|
1149
1155
|
if (!write_file)
|
@@ -1252,7 +1258,6 @@ int process (char *filename, char *write_file_name, unsigned int *width, unsigne
|
|
1252
1258
|
i++;
|
1253
1259
|
}
|
1254
1260
|
fclose (write_file);
|
1255
|
-
free (write_file_name);
|
1256
1261
|
reset_chunks ();
|
1257
1262
|
|
1258
1263
|
return 1;
|
@@ -1283,7 +1288,7 @@ VALUE method_pngdefry_dimensions(VALUE self, VALUE input);
|
|
1283
1288
|
|
1284
1289
|
void Init_pngdefry() {
|
1285
1290
|
Pngdefry = rb_define_module("Pngdefry");
|
1286
|
-
rb_define_singleton_method(Pngdefry, "
|
1291
|
+
rb_define_singleton_method(Pngdefry, "_defry", method_pngdefry_defry, 2);
|
1287
1292
|
rb_define_singleton_method(Pngdefry, "dimensions", method_pngdefry_dimensions, 1);
|
1288
1293
|
}
|
1289
1294
|
|
data/lib/pngdefry.rb
CHANGED
@@ -1,2 +1,13 @@
|
|
1
1
|
require 'pngdefry/version'
|
2
2
|
require File.expand_path('../pngdefry.bundle', __FILE__)
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Pngdefry
|
6
|
+
def self.defry(input, output)
|
7
|
+
# Ensure the output directory exists
|
8
|
+
FileUtils.mkdir_p(File.dirname(output))
|
9
|
+
|
10
|
+
# Defry in C
|
11
|
+
_defry(input, output)
|
12
|
+
end
|
13
|
+
end
|
data/lib/pngdefry/version.rb
CHANGED
data/test/data/40@2x.png
ADDED
Binary file
|
data/test/data/60@2x.png
ADDED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'dimensions'
|
3
|
+
|
4
|
+
class PngdefryTest < MiniTest::Test
|
5
|
+
def test_version_number
|
6
|
+
refute_nil Pngdefry::VERSION
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_defry
|
10
|
+
# Remove tmp dir to make sure it will create it
|
11
|
+
FileUtils.rm_rf('tmp')
|
12
|
+
|
13
|
+
# Fried PNGs give back crap dimensions
|
14
|
+
refute_equal [80, 80], Dimensions.dimensions('test/data/40@2x.png')
|
15
|
+
|
16
|
+
# Defry it
|
17
|
+
Pngdefry.defry('test/data/40@2x.png', 'tmp/40@2x.png')
|
18
|
+
|
19
|
+
# Now we should have the proper dimensions
|
20
|
+
assert_equal [80, 80], Dimensions.dimensions('tmp/40@2x.png')
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_dimensions
|
24
|
+
assert_equal [80, 80], Pngdefry.dimensions('test/data/40@2x.png')
|
25
|
+
assert_equal [120, 120], Pngdefry.dimensions('test/data/60@2x.png')
|
26
|
+
end
|
27
|
+
|
28
|
+
def teardown
|
29
|
+
FileUtils.rm_rf('tmp')
|
30
|
+
end
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pngdefry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Soffes
|
@@ -46,6 +46,10 @@ files:
|
|
46
46
|
- lib/pngdefry.rb
|
47
47
|
- lib/pngdefry/version.rb
|
48
48
|
- pngdefry.gemspec
|
49
|
+
- test/data/40@2x.png
|
50
|
+
- test/data/60@2x.png
|
51
|
+
- test/pngdefry_test.rb
|
52
|
+
- test/test_helper.rb
|
49
53
|
homepage: https://github.com/soffes/pngdefry
|
50
54
|
licenses:
|
51
55
|
- MIT
|
@@ -70,4 +74,8 @@ rubygems_version: 2.0.3
|
|
70
74
|
signing_key:
|
71
75
|
specification_version: 4
|
72
76
|
summary: Un-iPhone-PNGCrush PNGs
|
73
|
-
test_files:
|
77
|
+
test_files:
|
78
|
+
- test/data/40@2x.png
|
79
|
+
- test/data/60@2x.png
|
80
|
+
- test/pngdefry_test.rb
|
81
|
+
- test/test_helper.rb
|