Loading

imagemagick-图片

使用工具

png

便携式网络图形是一种无损压缩的位图片形格式,其设计目的是试图替代GIF和TIFF文件格式,同时增加一些GIF文件格式所不具备的特性。PNG使用从LZ77派生的无损数据压缩算法,一般应用于JAVA程序、网页或S60程序中,原因是它压缩比高,生成文件体积小。 *无损压缩的位图图形格式*
#官网  https://imagemagick.org/    

##安装方式
https://imagemagick.org/script/download.php


##ubuntu1604 
sudo apt-get install imagemagick
##centos 
yum  -y  install ImageMagick

##查看图像尺寸
identify logo.jpg
file logo.jpg

>>1 获取一张图片,调整像素大小,作为背景
convert  -resize  800x600  bga.png  bg.png 

>>2 以该背景图片作为基础,合成新图片,解决目标图片尺寸不一致问题
convert  bg.png 1.png   -gravity northwest -geometry   +0+0 -composite  t1.png  
convert  bg.png 2.png   -gravity northwest -geometry +0+0 -composite  t2.png   


>>3 合并已修正的图片为gif格式
convert -delay   600  t[0-9].png  tt.gif

################################################################################

## convert 命令格式
-resize widthxheight{%} {@} {!} {<} {>} {^}

##生成指定颜色的图片
convert -size 800x600  xc:"#f396eb"  bg.png




##转换图像格式
convert a.jpg b.png  #将 jpg 转换png

##缩放图像
convert imgyd064_R1_9_t_1.jpg -resize 200x100 imgyd064_R1_9_t_1_resize.jpg    #在保证原比例基础上缩放,一般以原比例进行操作
convert imgyd064_R1_9_t_1.jpg -resize 200x100! imgyd064_R1_9_t_1_resize.jpg   #强制缩放比例2:1


##旋转图像
convert imgyd064_R1_9_t_1.jpg -rotate 90 imgyd064_R1_9_t_1_rotate.jpg   #顺时针旋转90度

##添加文字
convert -fill black -pointsize 60 -font helvetica -draw  'text 10,80 "Hello, World!" ‘  hello.jpg  helloworld.jpg

用Python的mutagen模块获取MP3音频文件的时长

https://blog.csdn.net/u011519550/article/details/84981585

from pydub.utils import mediainfo
song = mediainfo("./(李豁子离婚)全场 胡希华.mp3")
print(song['duration'])

import librosa
time = librosa.get_duration(filename='./(李豁子离婚)全场 胡希华.mp3')
print(time)

操作历史


 1343  identify  1.png 
 1344  magick logo: gif:- | display gif:-
 1345  sudo  apt install  imagemagick
 1346  convert -size 200x200 xc:"#f396eb" bg.png
 1347  convert  bg.png 1.png --composite  tt.png
 1348  convert -size 200x200 xc:"#f396eb" bg.gif
 1349  identify bg.gif 
 1350  convert  bg.gif  1.png --composite  tt.gif
 1351  identify  1.png 
 1352  convert -size 800x600  xc:"#f396eb" bg.gif
 1353  convert  bg.gif  1.png --composite  tt.gif
 1354  convert  bg.gif  1.png 2.png   --composite  tt.gif
 1355  convert -delay 50 bg.gif 1.png 2.png 3.png tt.gif
 1356  convert  1.png  bg.gif -gravity northwest -geometry 69X69+6.0+6.0 -composite  tt.png
 1357  convert -size 800x600  xc:"#f396eb"  bg.png
 1358  convert  1.png  bg.gif -gravity northwest -geometry 69X69+6.0+6.0 -composite  tt.png
 1359  convert  1.png  bg.png -gravity northwest -geometry 69X69+6.0+6.0 -composite  tt.png
 1360  convert  bg.png 1.png   -gravity northwest -geometry 69X69+6.0+6.0 -composite  tt.png
 1361  convert  bg.png 1.png   -gravity northwest -geometry +0+0 -composite  tt.png
 1362  convert  bg.png 2.png   -gravity northwest -geometry +0+0 -composite  tt1.png
 1363  convert  bg.png 3.png   -gravity northwest -geometry +0+0 -composite  tt2.png
 1364  convert  bg.png 4.png   -gravity northwest -geometry +0+0 -composite  tt3.png
 1365  convert -delay 50  tt.png tt1.png tt2.png tt3.png  uu.gif 
 1366  convert -delay  60   tt.png tt1.png tt2.png tt3.png  uu.gif 
 1367  convert -delay  100   tt.png tt1.png tt2.png tt3.png  uu.gif 
 1368  convert -delay   150    tt.png tt1.png tt2.png tt3.png  uu.gif 
 1369  convert  th.jpeg   bga.png
 1370  identify  bga.png 
 1371  convert  -resize  800x600  bga.png 
 1372  convert  -resize  800x600  bga.png  bbb.png 
 1373  identify bbb.png 
 1374  convert  -resize  800x600  bga.png  bbb.png 
 1375  convert  th.jpeg   bga.png
 1376  convert  -resize  800x600  bga.png  bbb.png 
 1377  convert  bg.png 1.png   -gravity northwest -geometry +0+0 -composite  t1.png
 1378  convert  bg.png 2.png   -gravity northwest -geometry +0+0 -composite  t2.png
 1379  convert  bg.png 3.png   -gravity northwest -geometry +0+0 -composite  t3.png
 1380  convert  bg.png 4.png   -gravity northwest -geometry +0+0 -composite  t4.png
 1381  convert -delay   150  4*.png  tt.gif
 1382  convert -delay   150  t[0-9].png  tt.gif
 1383  convert -delay   300  t[0-9].png  tt.gif
 1384  convert -delay   600  t[0-9].png  tt.gif
 1385  convert -fill black -pointsize 60 -font helvetica -draw 'text 10,80 "@g2thend" ' bg.png    bg11.png
 1386  convert -fill black -pointsize 60 -font helvetica -draw 'text 10,80 "@g2thend" '  bg.png    bg11.png
 1387  convert -fill red  -pointsize 60 -font helvetica -draw 'text 10,80 "@g2thend" '  bg.png    bg11.png
 1388  convert -fill red  -pointsize 60 -font helvetica -draw 'text 500,500 "@g2thend" '  bg.png    bg11.png
 1389  convert -fill red  -pointsize 20 -font helvetica -draw 'text 550,500 "@g2thend" '  bg.png    bg11.png
 1390  convert -fill red  -pointsize 40 -font helvetica -draw 'text 580,580 "@g2thend" '  bg.png    bg11.png
 1391  convert -fill red  -pointsize 40 -font helvetica -draw 'text 580,590 "@g2thend" '  bg.png    bg11.png
 1392  identify  bbg.jpg 
 1393  convert  bbg.jpg   bbg.png
 1394  identify  bbg.png 
 1395  convert  bbg.png  -crop  800x600+0+0   bbgt.png 
 1396  identify  bbgt.png 
 1397  rm -rf bbgt.png
 1398  convert  bbg.png  -crop  800x600+0+200   bbgt.png 
 1399  convert -fill red  -pointsize 40 -font helvetica -draw 'text 780,590 "@g2thend" '  bbgt.png   bg.png
 1400  convert -fill red  -pointsize 40 -font helvetica -draw 'text 720,590 "@g2thend" '  bbgt.png   bg.png
 1401  identify  bbgt.png 
 1402  convert -fill red  -pointsize 40 -font helvetica -draw 'text 700,590 "@g2thend" '  bbgt.png   bg.png
 1403  convert -fill red  -pointsize 40 -font helvetica -draw 'text 900,500 "@g2thend" '  bbgt.png   bg.png
 1404  convert -fill red  -pointsize 40 -font helvetica -draw 'text 700,500 "@g2thend" '  bbgt.png   bg.png
 1405  convert -fill red  -pointsize 40 -font helvetica -draw 'text 730,500 "@g2thend" '  bbgt.png   bg1.png
 1406  convert -fill red  -pointsize 40 -font helvetica -draw 'text 650,600 "@g2thend" '  bbgt.png   bg1.png
 1407  convert -fill red  -pointsize 40 -font helvetica -draw 'text 600,680 "@g2thend" '  bbgt.png   bg1.png
 1408  convert -fill red  -pointsize 40 -font helvetica -draw 'text 600,700 "@g2thend" '  bbgt.png   bg1.png
 1409  convert -fill red  -pointsize 40 -font helvetica -draw 'text 600,720 "@g2thend" '  bbgt.png   bg1.png
 1410  convert -fill red  -pointsize 40 -font helvetica -draw 'text 600,750 "@g2thend" '  bbgt.png   bg1.png
 1411  convert -fill red  -pointsize 40 -font helvetica -draw 'text 600,760 "@g2thend" '  bbgt.png   bg1.png
 1412  convert -fill red  -pointsize 40 -font helvetica -draw 'text 600,770 "@g2thend" '  bbgt.png   bg1.png
 1413  mv bg1.png  bg.png
 1414  convert  bg.png 1.png   -gravity northwest -geometry   +0+0 -composite  t1.png 
 1415  convert  bg.png 2.png   -gravity northwest -geometry   +0+0 -composite  t2.png 
 1416  convert  bg.png 3.png   -gravity northwest -geometry   +0+0 -composite  t3.png 
 1417  convert  bg.png 4.png   -gravity northwest -geometry   +0+0 -composite  t4.png 
 1418  convert -delay   600  t[0-9].png  tt.gif
 1419  identify  bg.jpg 
 1420  convert   bg.jpg bg.png
 1421  identify  bg.png 
 1422  convert -fill red  -pointsize 40 -font helvetica -draw 'text 720,560 "@g2thend" '  bbgt.png   bg.png
 1423  convert -fill red  -pointsize 40 -font helvetica -draw 'text 720,560 "@g2thend" '  bg..png   b.png
 1424  convert -fill red  -pointsize 40 -font helvetica -draw 'text 720,560 "@g2thend" '  bg.png   b.png
 1425  convert -fill red  -pointsize 40 -font helvetica -draw 'text 70,560 "@g2thend" '  bg.png   b.png
 1426  convert -fill red  -pointsize 40 -font helvetica -draw 'text 700,560 "@g2thend" '  bg.png   b.png
 1427  convert -fill red  -pointsize 20 -font helvetica -draw 'text 700,560 "@g2thend" '  bg.png   b.png
 1428  convert -fill red  -pointsize 30 -font helvetica -draw 'text 690,570 "@g2thend" '  bg.png   b.png
 1429  convert -fill red  -pointsize 30 -font helvetica -draw 'text 660,570 "@g2thend" '  bg.png   b.png
 1430  convert -fill red  -pointsize 30 -font helvetica -draw 'text 650,580 "@g2thend" '  bg.png   b.png
 1431  mv b.png  bg.png
 1432  convert  bg.png 1.png   -gravity northwest -geometry   +0+0 -composite  t1.png
 1433  convert  bg.png 2.png   -gravity northwest -geometry   +0+0 -composite  t2.png
 1434  convert  bg.png 3.png   -gravity northwest -geometry   +0+0 -composite  t3.png
 1435  convert  bg.png 4.png   -gravity northwest -geometry   +0+0 -composite  t4.png
 1436  convert -delay   600  t[0-9].png  tt.gif
 1437  convert -delay   400  t[0-9].png  tt.gif


posted @ 2020-04-04 12:32  Lust4Life  阅读(287)  评论(0编辑  收藏  举报