<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:media="http://search.yahoo.com/mrss/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>圖型壓縮 &#8211; 馬修 IT</title>
	<atom:link href="https://blog.ocam.live/archives/tag/%E5%9C%96%E5%9E%8B%E5%A3%93%E7%B8%AE/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.ocam.live</link>
	<description>生活中所接觸各種電腦及網路問題與懷舊模擬器的專業問題解決與新資訊介紹的網站</description>
	<lastBuildDate>Tue, 29 Apr 2025 09:07:22 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.ocam.live/wp-content/uploads/2025/03/cropped-logo-1-300x300.png</url>
	<title>圖型壓縮 &#8211; 馬修 IT</title>
	<link>https://blog.ocam.live</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WordPress 簡單手動壓縮媒體庫</title>
		<link>https://blog.ocam.live/archives/3759</link>
		
		<dc:creator><![CDATA[blog.ocam.live]]></dc:creator>
		<pubDate>Mon, 28 Apr 2025 12:52:00 +0000</pubDate>
				<category><![CDATA[IT 日常]]></category>
		<category><![CDATA[程式設言]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[圖型壓縮]]></category>
		<guid isPermaLink="false">https://blog.ocam.live/?p=3759</guid>

					<description><![CDATA[為何要手動壓縮不能用外掛嗎？ 當然可用外掛。但有時會了減少外掛的安裝量進而影響網站後台的執行速度，此時就可以考 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="為何要手動壓縮不能用外掛嗎？">為何要手動壓縮不能用外掛嗎？</h2>



<p>當然可用外掛。但有時會了減少外掛的安裝量進而影響網站後台的執行速度，此時就可以考慮用手動執行指令的方式來壓縮圖片。而且手動壓縮的指令是有彈性的，Wordpress 的管理者可自由的搭配使用。</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>文章大綱</h2><nav><ul><li class=""><a href="#為何要手動壓縮不能用外掛嗎？">為何要手動壓縮不能用外掛嗎？</a></li><li class=""><a href="#主機是否有必要條件？">主機是否有必要條件？</a></li><li class=""><a href="#如何下指令？">如何下指令？</a></li><li class=""><a href="#手動壓縮完圖型的好處">手動壓縮完圖型的好處</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="主機是否有必要條件？">主機是否有必要條件？</h2>



<p>有。一般如果是自行架設的主機或 VPC 可用下方的指令先把必要的程式裝起來 。如果你是 wordpress 的網站是放 cloudways 上，該主機已有內建該程式，不用特地用下方的程式裝。可直接用手動的 command 切到特定目錄壓縮</p>



<pre class="wp-block-code"><code>sudo apt-get install imagemagick
安裝必要的程式</code></pre>



<h2 class="wp-block-heading" id="如何下指令？">如何下指令？</h2>



<pre class="wp-block-code"><code>1：SSH 到你的主機
2：切換到你的媒體庫目錄。媒體庫目錄通常在 wp-content/upload/年份。如 wp-content/upload/2025
3：在該目錄下執行
find . -type f -size +2M -exec mogrify -resize 50% {} \;
#指令為 在這個目錄下檔案超過 2M 的圖檔把它壓縮成原本的 50 % </code></pre>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="970" height="268" src="https://blog.ocam.live/wp-content/uploads/2025/04/find_image.png" alt="wordpress 圖型壓縮" class="wp-image-3763" title="Wordpress 簡單手動壓縮媒體庫" srcset="https://blog.ocam.live/wp-content/uploads/2025/04/find_image.png 970w, https://blog.ocam.live/wp-content/uploads/2025/04/find_image-600x166.png 600w, https://blog.ocam.live/wp-content/uploads/2025/04/find_image-860x238.png 860w, https://blog.ocam.live/wp-content/uploads/2025/04/find_image-768x212.png 768w" sizes="(max-width: 970px) 100vw, 970px" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.ocam.live/wp-content/uploads/2025/04/find_image_command-1024x185.png" alt="find image command" class="wp-image-3764" title="Wordpress 簡單手動壓縮媒體庫"></figure>



<p>執行完指令碼就會開始壓縮。這邊我是建議請在主機不忙的時間處理。因為圖型重新壓縮會吃掉大量 CPU 時間。為了避免影響網站服務。不過假設你自身的主機夠強就不在此限。</p>



<p>當然你也可以依每月壓縮一次。也就是把目錄切換到分月即可。如</p>



<pre class="wp-block-code"><code>cd /var/www/html/wp-content/uploads/2025/04
#切換到 4 月的檔案目錄</code></pre>



<h2 class="wp-block-heading" id="手動壓縮完圖型的好處">手動壓縮完圖型的好處</h2>



<ul class="wp-block-list">
<li><strong>加快網站載入速度</strong><br>圖片檔案太大會拖慢網站速度，壓縮後可以縮小檔案大小，加速網頁打開的時間，提升使用者體驗。</li>



<li><strong>減少伺服器儲存空間</strong><br>媒體庫如果上傳未壓縮的原始檔，會很快占滿伺服器空間。壓縮可以節省硬碟容量，降低主機成本。</li>



<li><strong>提升 SEO 表現</strong><br>Google 會根據網頁載入速度影響 SEO 排名。圖片檔案輕量化可以讓網站更容易拿到好排名。</li>



<li><strong>適應不同螢幕裝置</strong><br>WordPress 上傳圖片時，通常會自動產生多種尺寸（例如縮圖、中型、大型），每個裝置（手機、平板、桌機）可以載入最適合大小的圖片，進一步優化效能。</li>



<li><strong>避免使用者體驗斷裂</strong><br>如果圖片太大，在行動網路環境（例如 4G、5G）可能會很慢或載入失敗，壓縮後可以減少這種情況。</li>
</ul>


<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-7280d78" id="x-68000-games-supporting" data-block-id="7280d78"><h2 class="stk-block-heading__text">延伸閱讀</h2></div><div class="reading-grid"><a href="https://blog.ocam.live/archives/3923" class="card">
      <img decoding="async" width="300" height="300" src="https://blog.ocam.live/wp-content/uploads/2025/05/build_a_function_by_using_chatgpt-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="build_a_function_by_using_chatgpt" title="Wordpress 簡單手動壓縮媒體庫">
      <div class="card-content">
        <div class="card-title">用 ChatGPT 寫 WordPress 程式</div>
      </div>
		</a><a href="https://blog.ocam.live/archives/4415" class="card">
      <img decoding="async" width="300" height="300" src="https://blog.ocam.live/wp-content/uploads/2025/11/feedzyRss-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="feedzy Rss modify" title="Wordpress 簡單手動壓縮媒體庫">
      <div class="card-content">
        <div class="card-title">RSS Aggregator by Feedzy 免費版外掛改造</div>
      </div>
		</a><a href="https://blog.ocam.live/archives/3965" class="card">
      <img loading="lazy" decoding="async" width="300" height="300" src="https://blog.ocam.live/wp-content/uploads/2025/05/super-mario-64-pc-port-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="super mario 64 pc port" title="Wordpress 簡單手動壓縮媒體庫">
      <div class="card-content">
        <div class="card-title">Batocera 新增超級瑪利歐64原生 Linux 版</div>
      </div>
		</a></div></ul>
]]></content:encoded>
					
		
		
		<media:content url="https://blog.ocam.live/wp-content/uploads/2025/04/image_compress.jpg" medium="image"></media:content>
            	</item>
	</channel>
</rss>
