function validateJPEG(filePath){
    try {
        // May cause exception - bad disconnect from client?
        var buffer = readChunk.sync(filePath, 0, 12);
    } catch(e) {
        logger.error(e);
    }
    var type = imageType(buffer);
    if(type == null){
        logger.info("Not an image type: " + filePath);
        return false;
    }
    if( (type.ext == 'jpg'||type.ext == 'jpeg') && type.mime == 'image/jpeg' ){
        return true;
    } else {
        logger.info("Invalid image type: " + filePath);
        return false;
    }

}
/**
 * Validate image file
 * @param filePath {String} Path of the file to validate
 * @returns IsValid {boolean} If the file is a valid JPEG
 */
Validate image file
@param filePath {String} Path of the file to validate
@returns IsValid {boolean} If the file is a valid JPEG
Validate image file @param filePath { String } Path of the file to validate @returns IsValid { boolean } If the file is a valid JPEG
function validateJPEG(filePath){
    try {
        var buffer = readChunk.sync(filePath, 0, 12);
    } catch(e) {
        logger.error(e);
    }
    var type = imageType(buffer);
    if(type == null){
        logger.info("Not an image type: " + filePath);
        return false;
    }
    if( (type.ext == 'jpg'||type.ext == 'jpeg') && type.mime == 'image/jpeg' ){
        return true;
    } else {
        logger.info("Invalid image type: " + filePath);
        return false;
    }
}
function validateJPEG ( filePath ) { try { var buffer = readChunk . sync ( filePath , 0 , 12 ) ; } catch ( e ) { logger . error ( e ) ; } var type = imageType ( buffer ) ; if ( type == null ) { logger . info ( "Not an image type: " + filePath ) ; return false ; } if ( ( type . ext == 'jpg' || type . ext == 'jpeg' ) && type . mime == 'image/jpeg' ) { return true ; } else { logger . info ( "Invalid image type: " + filePath ) ; return false ; } }
Validate image file
 @param filePath {String} Path of the file to validate
 @returns IsValid {boolean} If the file is a valid JPEG
Validate image file @param filePath { String } Path of the file to validate @returns IsValid { boolean } If the file is a valid JPEG
// May cause exception - bad disconnect from client?