corrade-nucleus-nucleons – Blame information for rev 36
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
36 | office | 1 | |
2 | /** |
||
3 | * Extend proto. |
||
4 | */ |
||
5 | |||
6 | module.exports = function (proto) { |
||
7 | |||
8 | var exifTransforms = { |
||
9 | topleft: '' |
||
10 | , topright: ['-flop'] |
||
11 | , bottomright: ['-rotate', 180] |
||
12 | , bottomleft: ['-flip'] |
||
13 | , lefttop: ['-flip', '-rotate', 90] |
||
14 | , righttop: ['-rotate', 90] |
||
15 | , rightbottom: ['-flop', '-rotate', 90] |
||
16 | , leftbottom: ['-rotate', 270] |
||
17 | } |
||
18 | |||
19 | proto.autoOrient = function autoOrient () { |
||
20 | // Always strip EXIF data since we can't |
||
21 | // change/edit it. |
||
22 | |||
23 | // imagemagick has a native -auto-orient option |
||
24 | // so does graphicsmagick, but in 1.3.18. |
||
25 | // nativeAutoOrient option enables this if you know you have >= 1.3.18 |
||
26 | if (this._options.nativeAutoOrient || this._options.imageMagick) { |
||
27 | this.out('-auto-orient'); |
||
28 | this.strip(); |
||
29 | return this; |
||
30 | } |
||
31 | |||
32 | this.preprocessor(function (callback) { |
||
33 | this.orientation({bufferStream: true}, function (err, orientation) { |
||
34 | if (err) return callback(err); |
||
35 | |||
36 | var transforms = exifTransforms[orientation.toLowerCase()]; |
||
37 | if (transforms) { |
||
38 | |||
39 | // remove any existing transforms that might conflict |
||
40 | var index = this._out.indexOf(transforms[0]); |
||
41 | if (~index) { |
||
42 | this._out.splice(index, transforms.length); |
||
43 | } |
||
44 | |||
45 | // repage to fix coordinates |
||
46 | this._out.unshift.apply(this._out, transforms.concat('-page', '+0+0')); |
||
47 | } |
||
48 | |||
49 | this.strip(); |
||
50 | |||
51 | callback(); |
||
52 | }); |
||
53 | }); |
||
54 | |||
55 | return this; |
||
56 | } |
||
57 | } |