標籤:資源下載 根目錄 local 圖片 網頁
將圖片資源下載到網站的根目錄(/usr/local/httpd/htdocs/)下。
1.下載並解壓縮:
yum -y install ImageMagick ##安裝圖片轉換工具,支援convert
lftp ftp.linuxfan.cn
lftp ftp.linuxfan.cn:~> cd tools/
lftp ftp.linuxfan.cn:/tools> get for_html_img.tar.xz
164757244 bytes transferred
lftp ftp.linuxfan.cn:/tools> bye
tar Jxvf for_html_img.tar.xz ##解壓
cd img/
2.編寫指令碼:
[[email protected] img]# vim for_html.sh
#!/bin/bash
##建立相簿
echo "Creating album..."
mkdir -p thumbs
###########建立html頭部###############
cat <<EOF >index.html
<html>
<head>
<style type="text/css">
body {
width:960px;
margin:0 auto;
border:1px dashed grey;
padding:10px; background:#000;
}
img { margin:5px; border:1px solid black;}
h1 {
color:#fd6edf;
font-size:48px;
font-style:bold;
font-family:"華文行楷"; width:400px;
height:50px;
background:#eded56;
}
</style>
</head>
<body>
<center><h1>www.linuxfan.cn</h1></center>
<embed src="ibl.mp3" autostart=true loop=true></embed>
<p>
EOF
###########為所有圖片設定a標籤###################
for img in *.jpg;
do
convert "$img" -resize "300x" thumbs/$img ##將大圖轉為小圖並放到thumbs/目錄下
echo "<a href=\"$img\" target=\"_blank\"><img src=\"thumbs/$img\" title=\"$img\" /></a>" >>index.html
done
###############建立網頁的尾部###############
cat <<END >>index.html
</p>
</body>
</html>
END
echo "index.html is ok."
:wq
[[email protected] img]# sh -x for_html.sh
3.訪問測試:
http://www.linuxfan.cn/img
本文出自 “12289734” 部落格,請務必保留此出處http://12299734.blog.51cto.com/12289734/1908241
使用for迴圈產生網頁相簿