Linux convert命令有什么用

PHPz
Release: 2020-09-04 14:29:10
Original
2577 people have browsed it

Linux convert命令有什么用

Linux convert命令有什么用?

Linux强大的图片处理功能

强大的convert命令---介绍他的主要原因也是应为编程语言在linux下都可以调用使用

convent命令可以对图片进行各种处理

-trim:裁剪图像四周空白区域;

-transparent color:去除图像中指定的颜色;

-density geometry:设定图像的 DPI 值,若不明 DPI 值的概念,可参考《有关pt, px及DPI的知识》;

-antialias:让图像具有抗锯齿的效果;

-quality:图像压缩等级。

一/ 转换图片格式支持JPG, BMP, PCX, GIF, PNG, TIFF, XPM和XWD等类型

Ex:

convert  xxx.jpg  xxx.png  将jpeg转成png文件
convert  xxx.gif   xxx.bmp  将gif转换成bmp图像
convert  xxx.tiff    xxx.pcx   将tiff转换成pcx图像
convert -quality100-antialias -density96-transparent white -trim test.pdf test.png  将pdf转换为图片
Copy after login

二/改变图像的大小

EX:

convert -resize 1024x768  xxx.jpg  xxx1.jpg    将图像的像素改为1024*768,注意1024与768之间是小写字母x
convert -sample 50%x50%  xxx.jpg  xxx1.jpg   将图像的缩减为原来的50%*50%
convert result_60.jpg -crop wxh+dx+dy result_60.jpg
Copy after login

w为要截取图片的宽

h为要截取图片的高

注 :设置一边的压缩用^ 例如 500^ 那么压缩后的图片高为500 长度为等比例压缩 反之亦然

有时候会出现压缩不成功或者不是我们想要的尺寸 那么1024x768!就可以解决啦

convert antialias -quality 80  将图片质量压缩为原图的80%
Copy after login

三/旋转图像

convert -rotate 270 rotate-1.jpg  rotate-2.jpg      将图像顺时针旋转270度
Copy after login

四/使用-draw选项还可以在图像里面添加文字:

convert -fill black -pointsize 60 -font helvetica -draw 'text 10,80 "童小邪" ‘  hello.jpg  helloworld.jpg
Copy after login

在图像的10,80 位置采用60磅的全黑Helvetica字体写上 童小邪!

五/裁剪图片

convert  crop-1.jpg  -gravity -crop 1024x500 crop-2.jpg
Copy after login

六/图像拼接

横向拼接

convert 1.jpg 2.jpg 3.jpg +append result.jpg
Copy after login

纵向拼接

convert 1.jpg 2.jpg 3.jpg -append result.jpg
Copy after login

横向+纵向

convert /( 1.jpg 2.jpg 3.jpg +append /) /
/( 4.jpg 5.jpg 6.jpg +append /) /
/( 7.jpg 8.jpg 9.jpg +append /) /
-append result.jpg
Copy after login

更多相关技术文章,请访问PHP中文网

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!