linux 圖片轉換,php可用____linux

來源:互聯網
上載者:User

下載地址:
http://www.imagemagick.org/script/binary-releases.php#unix

檢查系統有無安裝ImageMagick
shell> rpm -qa | grep ImageMagick
沒有就開始安裝ImageMagick

shell> rpm -Uvh ImageMagick-6.3.4-10.i386.rpm
或者
shell> yum install ImageMagick

 

ImageMagick使用範例

1. 製作索引圖和動畫
!/bin/bash 
montage -bordercolor red -borderwidth 3 -label "%f" -tile 5x3 *.JPG montage.jpg 
mogrify -format gif *.JPG display montage.jpg animate *.JPG
2. 縮放 convert -sample 80x40 input.jpg output.jpg
注意:縮放後映像保持原來的長寬比例 convert -sample 25%x25% input.jpg output.jpg

 

3. 為目前的目錄的所有映像產生縮圖
for img in `ls *.jpg` 
do 
convert -sample 25%x25% $img thumb-$img 
done

 

4. 擷取檔案資訊 libtiff
tiffinfo filename.tiff 
pnginfo filename.png

 

5. 可以使用 ImageMagick 的 identify
identify -verbose sample.png 
identify -format "%wx%h" sample.png

 

6. 旋轉映像
convert -rotate 90 input.jpg output.jpg

 

7. 變更檔類型
convert input.jpg output.png

 

8. 為映像增加註釋文字
convert -font helvetica -fill white -pointsize 36 / 
-draw 'text 10,50 "Floriade 2002, Canberra, Australia"' / 
floriade.jpg comment.jpg 
convert -font fonts/1900805.ttf -fill white -pointsize 36 / 
-draw 'text 10,475 "stillhq.com"' / 
floriade.jpg stillhq.jpg

 

9. 特殊效果
convert -charcoal 2 input.jpg output.jpg #炭筆 
convert -colorize 255 input.jpg output.jpg #著色 可以指定三種顏色red/green/blue 
convert -implode 4 input.jpg output.jpg #內爆效果 
convert -solarize 42 input.jpg output.jpg #曝光,類比膠片曝光 
convert -spread 5 input.jpg output.jpg #隨機移動,參數是位移大小

 

10. 一次執行多個操作
convert -sample 25%x25% -spread 4 -charcoal 4 input.jpg output.jpg 

 

11. 按比例縮成固定大小
更多相關範例請參考下面地址:
http://www.imagemagick.org/Usage/thumbnails/
convert -size 300x300 hatching.jpg -thumbnail x200   -resize '200x<' -resize 50% -gravity center -crop 100x100+0+0 +repage cut_to_fit2.gif
convert 1182743797.jpg -thumbnail x168   -resize '252x<' -resize 50% -gravity center -crop 126x84+0+0 +repage -quality 90 thumb_1182743797.jpg

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.