<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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>SavvyAdmin.com &#187; Image Editing</title>
	<atom:link href="http://savvyadmin.com/tag/image-editing/feed/" rel="self" type="application/rss+xml" />
	<link>http://savvyadmin.com</link>
	<description>For savvy admins everywhere...</description>
	<lastBuildDate>Fri, 21 Jan 2011 17:53:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Resize and Watermark Images in Linux</title>
		<link>http://savvyadmin.com/resize-and-watermark-images-in-linux/</link>
		<comments>http://savvyadmin.com/resize-and-watermark-images-in-linux/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 02:35:13 +0000</pubDate>
		<dc:creator>gmendoza</dc:creator>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[Image Editing]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.savvyadmin.com/2007/12/30/resize-and-watermark-images-in-linux/</guid>
		<description><![CDATA[If you need to resize and watermark large number of images, there is an easy way to do so using Linux command line tools and a very basic shell script. The easiest and most straight-forward method you can use is through the use of the ImageMagick toolkit. If you don&#8217;t have it installed already, you [...]
Related posts:<ol>
<li><a href='http://savvyadmin.com/fixing-dates-in-image-exif-tag-data-from-linux/' rel='bookmark' title='Fixing Dates in Image EXIF Tag Data from Linux'>Fixing Dates in Image EXIF Tag Data from Linux</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you need to resize and watermark large number of images, there is an easy way to do so using Linux command line tools and a very basic shell script.  The easiest and most straight-forward method you can use is through the use of the <a title="ImageMagick" href="http://www.imagemagick.org" target="_blank">ImageMagick</a> toolkit.  If you don&#8217;t have it installed already, you can download it from their site.  Most distributions have binaries already built for you.  Ubuntu and Debian users can install ImageMagick from the main repositories.</p>
<p><strong>Install ImageMagick</strong></p>
<blockquote><p>
<code><strong>sudo apt-get install imagemagick</strong></code>
</p></blockquote>
<p><strong>Prepare your working environment</strong></p>
<p>Make a directory to store the watermark image (~/Pictures/watermark) and photos you&#8217;re working on (~/Pictures/temp).  Copy the watermark image and original photos to their respective directories.</p>
<blockquote><p><code><strong>mkdir -p ~/Pictures/temp/<br />
mkdir -p ~/Pictures/watermark/<br />
cp /path/to/watermark.jpg ~/Pictures/watermark/<br />
cp /path/to/original-photos/*.jpg ~/Pictures/temp/</strong></code></p>
<p><code><strong>ls -l ~/Pictures/watermark/</strong><br />
-rw-r--r-- 1 gmendoza gmendoza 3311 2007-12-30 17:35 watermark.jpg</code></p>
<p><code><strong>ls -l ~/Pictures/temp</strong><br />
-rw-r--r-- 1 gmendoza gmendoza 885788 2007-12-30 17:35 ubuntu1.jpg<br />
-rw-r--r-- 1 gmendoza gmendoza 128922 2007-12-30 17:31 ubuntu2.jpg</code></p></blockquote>
<p>Change directories to begin working on your photos.</p>
<blockquote><p>
<code><strong>cd ~/Pictures/temp/</strong></code>
</p></blockquote>
<p><strong>Resizing with &#8220;convert&#8221;</strong></p>
<p>Let&#8217;s say you want to specify a maximum width of 440 pixels (height being adjusted proportionally) in order for you to post the images appropriately within the specifications of your website borders.  The syntax would be the following:</p>
<blockquote><p>
<code><strong>convert -resize 440 original-image.jpg new-image.jpg</strong></code>
</p></blockquote>
<p>In this example, we will specify the same name for the output files, which will overwrite the original copies.</p>
<blockquote><p>
<code><strong>convert -resize 440 ubuntu1.jpg ubuntu1.jpg<br />
convert -resize 440 ubuntu2.jpg ubuntu2.jpg</strong></code>
</p></blockquote>
<p><strong>Watermark with &#8220;composite&#8221;</strong></p>
<p>You will probably want to watermark the images after they have been resized, this way there is no distortion of the watermark, and it is appropriately sized.   In this example, we will also set the watermark transparency level to 15%, and overwrite the original file again.</p>
<blockquote><p>
<code><strong>composite -gravity northeast -dissolve 15 ../watermark/watermark.jpg \<br />
ubuntu1.jpg ubuntu1.jpg<br />
composite -gravity northeast -dissolve 15 ../watermark/watermark.jpg \<br />
ubuntu2.jpg ubuntu2.jpg</strong></code>
</p></blockquote>
<p>Your photos will now have a nice watermark in their upper right hand corners.</p>
<p><strong>Automating the process with a script</strong></p>
<p>You can automate these steps and apply them to a large number of files using a script of course.  Feel free to download this one and modify it to your liking.</p>
<p><a title="Watermark Script" href="http://www.savvyadmin.com/downloads/watermark.sh" target="_blank">http://www.savvyadmin.com/downloads/watermark.sh</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">WATERMARK</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Pictures/watermark/watermark.jpg&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;*****************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;* Image Resize and Watermarking Script  *&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;* By Gilbert Mendoza -  SavvyAdmin.com! *&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;*****************************************&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; &quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> each <span style="color: #000000; font-weight: bold;">in</span> ~<span style="color: #000000; font-weight: bold;">/</span>Pictures<span style="color: #000000; font-weight: bold;">/</span>temp<span style="color: #000000; font-weight: bold;">/*</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>.jpg,.jpeg,.png<span style="color: #7a0874; font-weight: bold;">&#125;</span>
 <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Working on &quot;</span><span style="color: #007800;">$each</span><span style="color: #ff0000;">&quot; ...&quot;</span>
  convert <span style="color: #660033;">-resize</span> <span style="color: #000000;">440</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$each</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$each</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
  composite <span style="color: #660033;">-gravity</span> northeast <span style="color: #660033;">-dissolve</span> <span style="color: #000000;">15.3</span> <span style="color: #007800;">$WATERMARK</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$each</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$each</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;... Done!&quot;</span>
 <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p><strong>Additional Options</strong></p>
<p>Please check out the ImageMagick website for more information on the many options and features their products have to offer.</p>
<p><a title="ImageMagick CLI Processing" href="http://www.imagemagick.org/script/command-line-processing.php" target="_blank">http://www.imagemagick.org/script/command-line-processing.php</a></p>
<p><a title="ImageMagick CLI Options" href="http://www.imagemagick.org/script/command-line-options.php" target="_blank">http://www.imagemagick.org/script/command-line-options.php</a></p>
<p><a title="ImageMagick Usage" href="http://www.imagemagick.org/Usage" target="_blank">http://www.imagemagick.org/Usage</a></p>
<p>Related posts:<ol>
<li><a href='http://savvyadmin.com/fixing-dates-in-image-exif-tag-data-from-linux/' rel='bookmark' title='Fixing Dates in Image EXIF Tag Data from Linux'>Fixing Dates in Image EXIF Tag Data from Linux</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://savvyadmin.com/resize-and-watermark-images-in-linux/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

