Skip to content

Commit

Permalink
force a higher precision for better file sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
aeh committed Mar 26, 2018
1 parent 3d80028 commit dc9481a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports.cmd = function(path, opts) {
(opts.exif ? '%[exif:*]' : '')
].join("\n");

return 'convert -ping ' + path + ' -format "' + format + '" info:';
return 'convert -ping ' + path + ' -format "' + format + '" -precision 12 info:';
};

module.exports.parse = function(path, stdout, opts) {
Expand Down
10 changes: 4 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ describe('metadata.cmd()', function() {
it('returns command without exif data', function() {
var cmd = 'convert -ping /foo/bar/baz -format "name=\nsize=%b\nformat=%m\n'
+ 'colorspace=%[colorspace]\nheight=%[height]\nwidth=%[width]\n'
+ 'orientation=%[orientation]\n" info:';
+ 'orientation=%[orientation]\n" -precision 12 info:';

assert.equal(metadata.cmd('/foo/bar/baz'), cmd);
});

it('returns command with exif data', function() {
var cmd = 'convert -ping /foo/bar/baz -format "name=\nsize=%b\nformat=%m\n'
+ 'colorspace=%[colorspace]\nheight=%[height]\nwidth=%[width]\n'
+ 'orientation=%[orientation]\n%[exif:*]" info:';
+ 'orientation=%[orientation]\n%[exif:*]" -precision 12 info:';

assert.equal(metadata.cmd('/foo/bar/baz', {exif: true}), cmd);
});
Expand Down Expand Up @@ -111,9 +111,7 @@ describe('metadata()', function() {

assert.equal(data.path, './assets/image.jpg');
assert.equal(data.name, '');
// allow for precision errors. image magick returns 5 decimal places for
// me locally on OSX vs 3 decimal places on linux.
assert.equal(data.size - data.size % 1000, 4504000);
assert.equal(data.size, 4295828);
assert.equal(data.format, 'JPEG');
assert.equal(data.colorspace, 'RGB');
assert.equal(data.height, 3456);
Expand All @@ -132,7 +130,7 @@ describe('metadata()', function() {

assert.equal(data.path, './assets/image.jpg');
assert.equal(data.name, '');
assert.equal(data.size - data.size % 1000, 4504000);
assert.equal(data.size, 4295828);
assert.equal(data.format, 'JPEG');
assert.equal(data.colorspace, 'RGB');
assert.equal(data.height, 3456);
Expand Down

0 comments on commit dc9481a

Please sign in to comment.