@@ -31,9 +31,9 @@ const sof = { 0xc0: true, 0xc1: true, 0xc2: true, 0xc3: true, 0xc5: true, 0xc6:
3131var child = require ( 'child_process' ) ;
3232var exec = child . exec ;
3333var spawn = child . spawn ;
34- var path = require ( 'path' ) ;
3534var middlewares = { } ;
3635var Fs = require ( 'fs' ) ;
36+ var framework_utils = require ( './utils' ) ;
3737
3838function u16 ( buf , o ) {
3939 return buf [ o ] << 8 | buf [ o + 1 ] ;
@@ -140,7 +140,7 @@ function Image(filename, useImageMagick, width, height) {
140140 this . filename = type === 'string' ? filename : null ;
141141 this . currentStream = type === 'object' ? filename : null ;
142142 this . isIM = useImageMagick === undefined || useImageMagick === null ? F . config [ 'default-image-converter' ] === 'im' : useImageMagick ;
143- this . outputType = type === 'string' ? path . extname ( filename ) . substring ( 1 ) : 'jpg' ;
143+ this . outputType = type === 'string' ? framework_utils . getExtension ( filename ) . substring ( 1 ) : 'jpg' ;
144144}
145145
146146/*
@@ -250,11 +250,8 @@ Image.prototype.save = function(filename, callback, writer) {
250250 var writer = Fs . createWriteStream ( filename + '_' ) ;
251251
252252 reader . pipe ( middleware ( ) ) . pipe ( writer ) ;
253-
254253 writer . on ( 'finish' , function ( ) {
255- Fs . rename ( filename + '_' , filename , function ( ) {
256- callback ( null , true ) ;
257- } ) ;
254+ Fs . rename ( filename + '_' , filename , ( ) => callback ( null , true ) ) ;
258255 } ) ;
259256 } ) ;
260257
@@ -804,3 +801,7 @@ exports.middleware = function(type, fn) {
804801 type = type . substring ( 1 ) ;
805802 middlewares [ type ] = fn ;
806803} ;
804+
805+ exports . restart = function ( ) {
806+ middlewares = { } ;
807+ } ;
0 commit comments