iOS 截屏以及相关扩展(UIImage的绘制和渲染)

2024-06-06 14:18

本文主要是介绍iOS 截屏以及相关扩展(UIImage的绘制和渲染),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.截取当前屏幕

  CGSize windowSize = behandView.bounds.size;
    UIGraphicsBeginImageContextWithOptions(windowSize, YES, 2.0);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [behandView.window.layer renderInContext:context];
    UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

2.截屏-scrollview


- (UIImage *)captureScrollView:(UIScrollView *)scrollView{
        UIImage* image = nil;
        UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, NO, 2.0f);
        {
            CGPoint savedContentOffset = scrollView.contentOffset;
            CGRect savedFrame = scrollView.frame;
            scrollView.contentOffset = CGPointZero;
            scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
            
            [scrollView.layer renderInContext: UIGraphicsGetCurrentContext()];
            image = UIGraphicsGetImageFromCurrentImageContext();
            
            scrollView.contentOffset = savedContentOffset;
            scrollView.frame = savedFrame;
        }
        UIGraphicsEndImageContext();
        
        if (image != nil)
        {
            return image;
        }


3.扩展知识,UIImage的绘制和渲染

UIGraphicsBeginImageContext系列知识

UIGraphicsBeginImageContext
创建一个基于位图的上下文(context),并将其设置为当前上下文(context)。方法声明如下:

 
 
void UIGraphicsBeginImageContext(CGSize size);

参数size为新创建的位图上下文的大小。它同时是由UIGraphicsGetImageFromCurrentImageContext函数返回的图形大小。
该函数的功能同UIGraphicsBeginImageContextWithOptions的功能相同,相当与UIGraphicsBeginImageContextWithOptions的opaque参数为NO,scale因子为1.0。

UIGraphicsBeginImageContextWithOptions
函数原型为:

 void UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale);  

size——同UIGraphicsBeginImageContext
opaque—透明开关,如果图形完全不用透明,设置为YES以优化位图的存储。
scale—–缩放因子

 

 

默认创建一个透明的位图上下

 

UIImageC处理

1、等比缩放

C代码

  1. - (UIImage *) scaleImage:(UIImage *)image toScale:(float)scaleSize {
  2. UIGraphicsBeginImageContext(CGSizeMake(image.size.width * scaleSize, image.size.height * scaleSize);
  3. [image drawInRect:CGRectMake(0, 0, image.size.width * scaleSize, image.size.height * scaleSize)];
  4. UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
  5. UIGraphicsEndImageContext();
  6. return scaledImage;
  7. }

 

2、自定义大小

C代码

  1. - (UIImage *) reSizeImage:(UIImage *)image toSize:(CGSize)reSize {
  2. UIGraphicsBeginImageContext(CGSizeMake(reSize.width, reSize.height));
  3. [image drawInRect:CGRectMake(0, 0, reSize.width, reSize.height)];
  4. UIImage *reSizeImage = UIGraphicsGetImageFromCurrentImageContext();
  5. UIGraphicsEndImageContext();
  6. return reSizeImage;
  7. }

 

3、处理某个特定的view

只要是继承UIViewobject 都可以处理
必须先import QuzrtzCore.framework

C代码

  1. -(UIImage*) captureView:(UIView *)theView {
  2. CGRect rect = theView.frame;
  3. UIGraphicsBeginImageContext(rect.size);
  4. CGContextRef context = UIGraphicsGetCurrentContext();
  5. [theView.layer renderInContext:context];
  6. UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
  7. UIGraphicsEndImageContext();
  8. return img;
  9. }

 

4、存储图片

4.1、存储到app的文件里

把要处理的图片以image.png的名字存储到apphome地下的Document目录中

 

C代码

  1. NSString *path = [[NSHomeDirectory()stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:@"image.png"];
  2. [UIImagePNGRepresentation(image) writeToFile:pathatomically:YES];

4.2、存储到手机的图片库中


  1. CGImageRef screen = UIGetScreenImage();
  2. UIImage* image = [UIImage imageWithCGImage:screen];
  3. CGImageRelease(screen);
  4. UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);

 

 

 

获取当前app的名称和版本号

 

 


  1. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  2. // app
  3. NSString *name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  4. // app版本
  5. NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
  6. // app build版本
  7. NSString *build = [infoDictionary objectForKey:@"CFBundleVersion"];

 

 

UILabel根据text自动调整大小

 


  1. label.text = @"**********";
  2. CGRect frame = label.frame;
  3. frame.size.height = 10000; // 置一很大的高度
  4. label.frame = frame;
  5. [label sizeToFit];
  6. frame.size.height = label.frame.size.height;
  7. label.frame = frame;

 

 


 

  1. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://01011112222,3333"]];

 


- (UIImage *)rescaleImage:(UIImage *)imgToSize:(CGSize)size; //图片缩放裁剪

- (UIImage*)transformWidth:(CGFloat)width height:(CGFloat)height;//改变大小

+ (UIImage *)addImage:(UIImage *)image1 toImage:(UIImage*)image2; //合并图片

+ (UIImage *)imageFromImage:(UIImage *)imageinRect:(CGRect)rect; //裁剪部分图片

+ (void)imageSavedToPhotosAlbum:(UIImage *)image

didFinishSavingWithError:(NSError *)errorcontextInfo:(void *)contextInfo; //保存图片到媒体库

 

零重新设置图片的尺寸

- (UIImage *)rescaleImage:(UIImage *)imgToSize:(CGSize)size {

CGRect rect = CGRectMake(0.0, 0.0, size.width,size.height);

UIGraphicsBeginImageContext(rect.size);

[img drawInRect:rect]; // scales image to rect

UIImage *resImage =UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return resImage;

}

-)根据给定得图片,从其指定区域截取一张新得图片

-(UIImage *)getImageFromImage{

//大图bigImage

//定义myImageRect,截图的区域

CGRect myImageRect = CGRectMake(10.0, 10.0, 57.0, 57.0);

UIImage* bigImage= [UIImageimageNamed:@"k00030.jpg"];

CGImageRef imageRef = bigImage.CGImage;

CGImageRef subImageRef =CGImageCreateWithImageInRect(imageRef, myImageRect);

CGSize size;

size.width = 57.0;

size.height = 57.0;

UIGraphicsBeginImageContext(size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextDrawImage(context, myImageRect, subImageRef);

UIImage* smallImage = [UIImageimageWithCGImage:subImageRef];

UIGraphicsEndImageContext();

return smallImage;

}

二) 合并两张图片

- (UIImage *)addImage:(UIImage *)image1 toImage:(UIImage*)image2 {

UIGraphicsBeginImageContext(image1.size);

// Draw image1

[image1 drawInRect:CGRectMake(0, 0, image1.size.width,image1.size.height)];

// Draw image2

[image2 drawInRect:CGRectMake(0, 0, image2.size.width,image2.size.height)];

UIImage *resultingImage =UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

returnresultingImage;

}

 

三) 捕捉屏幕截图

CALayer实例使用CoreGraphics的renderInContext方法可以将视图绘制到图像上下文中以便转化为其他UIImage实例。前提先#import

+ (UIImage *) imageFromView: (UIView *)theView{     // draw a view's contents into animage context   UIGraphicsBeginImageContext(theView.frame.size);    CGContextRef  context = UIGraphicsGetCurrentContext();     [theView.layer  renderInContext:context];    UIImage *theImage =UIGraphicsGetImageFromCurrentImageContext();   UIGraphicsEndImageContext();    return theImage; }

注:UIGraphicsBeginImageContext(CGSize size)创建一个基于位图的上下文(context),并将其设置为当前上下文。函数功能与UIGraphicsBeginImageContextWithOptions相同,相当于该方法的opaque参数为NO,scale因子为1.0。而UIGraphicsEndImageContext()方法是移除栈顶的基于当前位图的图形上下文。

视图添加倒影效果

const CGFloat kReflectPercent = -0.25f; constCGFloat kReflectOpacity = 0.3f; const CGFloat kReflectDistance = 10.0f;  + (void)addSimpleReflectionToView:(UIView*)theView {      CALayer *reflectionLayer= [CALayer layer];      reflectionLayer.contents= [theView layer].contents;     reflectionLayer.opacity = kReflectOpacity;      reflectionLayer.frame =CGRectMake(0.0f,0.0f,theView.frame.size.width,theView.frame.size.height*kReflectPercent);  //倒影层框架设置,其中高度是原视图的百分比   CATransform3D stransform = CATransform3DMakeScale(1.0f,-1.0f,1.0f);      CATransform3D transform =CATransform3DTranslate(stransform,0.0f,-(kReflectDistance +theView.frame.size.height),0.0f);     reflectionLayer.transform = transform;      reflectionLayer.sublayerTransform =reflectionLayer.transform;      [[theViewlayer] addSublayer:reflectionLayer]; }

另一:使用Core Graphics创建倒影

+ (CGImageRef) createGradientImage:(CGSize)size{       CGFloat colors[] ={0.0,1.0,1.0,1.0};       //在灰色设备色彩上建立一渐变    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();       CGContextRef context =CGBitmapContextCreate(nil,size.width,size.height,8,0,colorSpace,kCGImageAlphaNone);       CGGradientRef gradient =CGGradientCreateWithColorComponents(colorSpace,colors,NULL,2);       CGColorSpaceRelease(colorSpace);        //绘制线性渐变    CGPoint p1 = CGPointZero;      CGPoint p2 = CGPointMake(0,size.height);      CGContextDrawLinearGradient(context,gradient,p1,p2,kCGGradientDrawsAfterEndLocation);        //Return the CGImage      CGImageRef theCGImage =CGBitmapContextCreateImage(context);      CFRelease(gradient);      CGContextRelease(context);      return theCGImage; }

//Create a shrunken frame for the reflection

+ (UIImage *) reflectionOfView:(UIView *)theViewWithPercent:(CGFloat) percent {     //Retain the width but shrink the height     CGSize size =CGSizeMake(theView.frame.size.width, theView.frame.size.height * percent);       //Shrink the View     UIGraphicsBeginImageContext(size);      CGContextRef context =UIGraphicsGetCurrentContext();     [theView.layer renderInContext:context];      UIImage *partialimg =UIGraphicsGetImageFromCurrentImageContext();      UIGraphicsEndImageContext();       //build the mask     CGImageRef mask = [ImageHelpercreateGradientImage:size];     CGImageRef ref = CGImageCreateWithMask(partialimg.CGImage,mask);      UIImage *theImage = [UIImageimageWithCGImage:ref];     CGImageRelease(ref);     CGImageRelease(mask);      returntheImage; }  const CGFloatkReflectDistance = 10.0f; + (void) addReflectionToView: (UIView *)theView{      theView.clipsToBounds = NO;      UIImageView *reflection = [[UIImageViewalloc] initWithImage:[ImageHelper reflectionOfView:theView withPercent:0.45f]];      CGRect frame = reflection.frame;      frame.origin = CGPointMake(0.0f,theView.frame.size.height + kReflectDistance);      reflection.frame = frame;       // add the reflection as a simplesubview     [theViewaddSubView:reflection];      [reflectionrelease]; }

关于图片缩放的线程安全和非线程安全操作.

非线程安全的操作只能在主线程中进行操作,对于大图片的处理肯定会消耗大量的时间,如下面的方法

方法 1: 使用 UIKit

+ (UIImage*)imageWithImage INCLUDEPICTURE"http://www.61ic.com/Mobile/UploadFiles_9667/201103/20110309123315372.gif"\* MERGEFORMATINET UIImage*)image scaledToSize INCLUDEPICTURE"http://www.61ic.com/Mobile/UploadFiles_9667/201103/20110309123315372.gif"\* MERGEFORMATINET CGSize)newSize;

{

// Create a graphics image context

UIGraphicsBeginImageContext(newSize);

// Tell the old image to draw in this new context, withthe desired

// new size

[imagedrawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

// Get the new image from the context

UIImage* newImage =UIGraphicsGetImageFromCurrentImageContext();

// End the context

UIGraphicsEndImageContext();

// Return the new image.

return newImage;

}

此方法很简单, 但是,这种方法不是线程安全的情况下.

方法 2: 使用 CoreGraphics

+ (UIImage*)imageWithImage INCLUDEPICTURE "http://www.61ic.com/Mobile/UploadFiles_9667/201103/20110309123315372.gif" \* MERGEFORMATINET UIImage*)sourceImage scaledToSize INCLUDEPICTURE "http://www.61ic.com/Mobile/UploadFiles_9667/201103/20110309123315372.gif" \* MERGEFORMATINET CGSize)newSize;

{

CGFloat targetWidth = targetSize.width;

CGFloat targetHeight = targetSize.height;

CGImageRef imageRef = [sourceImage CGImage];

CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);

CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);

if (bitmapInfo == kCGImageAlphaNone) {

bitmapInfo = kCGImageAlphaNoneSkipLast;

}

CGContextRef bitmap;

if (sourceImage.imageOrientation == UIImageOrientationUp ||sourceImage.imageOrientation == UIImageOrientationDown) {

bitmap = CGBitmapContextCreate(NULL, targetWidth, targetHeight,CGImageGetBitsPerComponent(imageRef),CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo);

} else {

bitmap = CGBitmapContextCreate(NULL, targetHeight, targetWidth,CGImageGetBitsPerComponent(imageRef),CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo);

}

if (sourceImage.imageOrientation == UIImageOrientationLeft) {

CGContextRotateCTM (bitmap, radians(90));

CGContextTranslateCTM (bitmap, 0, -targetHeight);

} else if (sourceImage.imageOrientation ==UIImageOrientationRight) {

CGContextRotateCTM (bitmap, radians(-90));

CGContextTranslateCTM (bitmap, -targetWidth, 0);

} else if (sourceImage.imageOrientation == UIImageOrientationUp) {

// NOTHING

} else if (sourceImage.imageOrientation == UIImageOrientationDown){

CGContextTranslateCTM (bitmap, targetWidth, targetHeight);

CGContextRotateCTM (bitmap, radians(-180.));

}

CGContextDrawImage(bitmap, CGRectMake(0, 0, targetWidth,targetHeight), imageRef);

CGImageRef ref = CGBitmapContextCreateImage(bitmap);

UIImage* newImage = [UIImage imageWithCGImage:ref];

CGContextRelease(bitmap);

CGImageRelease(ref);

return newImage;

}

这种方法的好处是它是线程安全,加上它负责的 (使用正确的颜色空间和位图信息,处理图像方向) 的小东西,UIKit 版本不会。

如何调整和保持长宽比 (如 AspectFill 选项)?

它是非常类似于上述,方法,它看起来像这样:

+ (UIImage*)imageWithImage INCLUDEPICTURE "http://www.61ic.com/Mobile/UploadFiles_9667/201103/20110309123315372.gif" \* MERGEFORMATINET UIImage*)sourceImage scaledToSizeWithSameAspectRatio INCLUDEPICTURE "http://www.61ic.com/Mobile/UploadFiles_9667/201103/20110309123315372.gif" \* MERGEFORMATINET CGSize)targetSize;

{

CGSize imageSize = sourceImage.size;

CGFloat width = imageSize.width;

CGFloat height = imageSize.height;

CGFloat targetWidth = targetSize.width;

CGFloat targetHeight = targetSize.height;

CGFloat scaleFactor = 0.0;

CGFloat scaledWidth = targetWidth;

CGFloat scaledHeight = targetHeight;

CGPoint thumbnailPoint = CGPointMake(0.0,0.0);

if (CGSizeEqualToSize(imageSize, targetSize) == NO) {

CGFloat widthFactor = targetWidth / width;

CGFloat heightFactor = targetHeight / height;

if (widthFactor > heightFactor) {

scaleFactor = widthFactor; // scale to fit height

}

else {

scaleFactor = heightFactor; // scale to fit width

}

scaledWidth = width * scaleFactor;

scaledHeight = height * scaleFactor;

// center the image

if (widthFactor > heightFactor) {

thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;

}

else if (widthFactor < heightFactor) {

thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;

}

}

CGImageRef imageRef = [sourceImage CGImage];

CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);

CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);

if (bitmapInfo == kCGImageAlphaNone) {

bitmapInfo = kCGImageAlphaNoneSkipLast;

}

CGContextRef bitmap;

if (sourceImage.imageOrientation == UIImageOrientationUp ||sourceImage.imageOrientation == UIImageOrientationDown) {

bitmap = CGBitmapContextCreate(NULL, targetWidth, targetHeight,CGImageGetBitsPerComponent(imageRef),CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo);

} else {

bitmap = CGBitmapContextCreate(NULL, targetHeight, targetWidth,CGImageGetBitsPerComponent(imageRef),CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo);

}

// In the right or left cases, we need to switch scaledWidth and scaledHeight,

// and also the thumbnail point

if (sourceImage.imageOrientation == UIImageOrientationLeft) {

thumbnailPoint = CGPointMake(thumbnailPoint.y, thumbnailPoint.x);

CGFloat oldScaledWidth = scaledWidth;

scaledWidth = scaledHeight;

scaledHeight = oldScaledWidth;

CGContextRotateCTM (bitmap, radians(90));

CGContextTranslateCTM (bitmap, 0, -targetHeight);

} else if (sourceImage.imageOrientation ==UIImageOrientationRight) {

thumbnailPoint = CGPointMake(thumbnailPoint.y, thumbnailPoint.x);

CGFloat oldScaledWidth = scaledWidth;

scaledWidth = scaledHeight;

scaledHeight = oldScaledWidth;

CGContextRotateCTM (bitmap, radians(-90));

CGContextTranslateCTM (bitmap, -targetWidth, 0);

} else if (sourceImage.imageOrientation == UIImageOrientationUp) {

// NOTHING

} else if (sourceImage.imageOrientation == UIImageOrientationDown){

CGContextTranslateCTM (bitmap, targetWidth, targetHeight);

CGContextRotateCTM (bitmap, radians(-180.));

}

CGContextDrawImage(bitmap, CGRectMake(thumbnailPoint.x,thumbnailPoint.y, scaledWidth, scaledHeight), imageRef);

CGImageRef ref = CGBitmapContextCreateImage(bitmap);

UIImage* newImage = [UIImage imageWithCGImage:ref];

CGContextRelease(bitmap);

CGImageRelease(ref);

return newImage;

}

 



这篇关于iOS 截屏以及相关扩展(UIImage的绘制和渲染)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1036341

相关文章

csu 1446 Problem J Modified LCS (扩展欧几里得算法的简单应用)

这是一道扩展欧几里得算法的简单应用题,这题是在湖南多校训练赛中队友ac的一道题,在比赛之后请教了队友,然后自己把它a掉 这也是自己独自做扩展欧几里得算法的题目 题意:把题意转变下就变成了:求d1*x - d2*y = f2 - f1的解,很明显用exgcd来解 下面介绍一下exgcd的一些知识点:求ax + by = c的解 一、首先求ax + by = gcd(a,b)的解 这个

sqlite3 相关知识

WAL 模式 VS 回滚模式 特性WAL 模式回滚模式(Rollback Journal)定义使用写前日志来记录变更。使用回滚日志来记录事务的所有修改。特点更高的并发性和性能;支持多读者和单写者。支持安全的事务回滚,但并发性较低。性能写入性能更好,尤其是读多写少的场景。写操作会造成较大的性能开销,尤其是在事务开始时。写入流程数据首先写入 WAL 文件,然后才从 WAL 刷新到主数据库。数据在开始

安卓链接正常显示,ios#符被转义%23导致链接访问404

原因分析: url中含有特殊字符 中文未编码 都有可能导致URL转换失败,所以需要对url编码处理  如下: guard let allowUrl = webUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {return} 后面发现当url中有#号时,会被误伤转义为%23,导致链接无法访问

科研绘图系列:R语言扩展物种堆积图(Extended Stacked Barplot)

介绍 R语言的扩展物种堆积图是一种数据可视化工具,它不仅展示了物种的堆积结果,还整合了不同样本分组之间的差异性分析结果。这种图形表示方法能够直观地比较不同物种在各个分组中的显著性差异,为研究者提供了一种有效的数据解读方式。 加载R包 knitr::opts_chunk$set(warning = F, message = F)library(tidyverse)library(phyl

【WebGPU Unleashed】1.1 绘制三角形

一部2024新的WebGPU教程,作者Shi Yan。内容很好,翻译过来与大家共享,内容上会有改动,加上自己的理解。更多精彩内容尽在 dt.sim3d.cn ,关注公众号【sky的数孪技术】,技术交流、源码下载请添加微信号:digital_twin123 在 3D 渲染领域,三角形是最基本的绘制元素。在这里,我们将学习如何绘制单个三角形。接下来我们将制作一个简单的着色器来定义三角形内的像素

Flutter 进阶:绘制加载动画

绘制加载动画:由小圆组成的大圆 1. 定义 LoadingScreen 类2. 实现 _LoadingScreenState 类3. 定义 LoadingPainter 类4. 总结 实现加载动画 我们需要定义两个类:LoadingScreen 和 LoadingPainter。LoadingScreen 负责控制动画的状态,而 LoadingPainter 则负责绘制动画。

Spring框架5 - 容器的扩展功能 (ApplicationContext)

private static ApplicationContext applicationContext;static {applicationContext = new ClassPathXmlApplicationContext("bean.xml");} BeanFactory的功能扩展类ApplicationContext进行深度的分析。ApplicationConext与 BeanF

两个月冲刺软考——访问位与修改位的题型(淘汰哪一页);内聚的类型;关于码制的知识点;地址映射的相关内容

1.访问位与修改位的题型(淘汰哪一页) 访问位:为1时表示在内存期间被访问过,为0时表示未被访问;修改位:为1时表示该页面自从被装入内存后被修改过,为0时表示未修改过。 置换页面时,最先置换访问位和修改位为00的,其次是01(没被访问但被修改过)的,之后是10(被访问了但没被修改过),最后是11。 2.内聚的类型 功能内聚:完成一个单一功能,各个部分协同工作,缺一不可。 顺序内聚:

log4j2相关配置说明以及${sys:catalina.home}应用

${sys:catalina.home} 等价于 System.getProperty("catalina.home") 就是Tomcat的根目录:  C:\apache-tomcat-7.0.77 <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" /> 2017-08-10

Node Linux相关安装

下载经编译好的文件cd /optwget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.gztar -xvf node-v10.15.3-linux-x64.tar.gzln -s /opt/node-v10.15.3-linux-x64/bin/npm /usr/local/bin/ln -s /opt/nod