{"id":2315,"date":"2012-06-17T17:47:53","date_gmt":"2012-06-17T17:47:53","guid":{"rendered":"http:\/\/www.bartbusschots.ie\/blog\/?p=2315"},"modified":"2014-08-05T20:20:51","modified_gmt":"2014-08-05T20:20:51","slug":"webifyimages-pm-my-image-editing-scripts-v0-2","status":"publish","type":"post","link":"https:\/\/www.bartbusschots.ie\/s\/2012\/06\/17\/webifyimages-pm-my-image-editing-scripts-v0-2\/","title":{"rendered":"WebifyImages.pm &#8211; My Image Editing Scripts (v0.2)"},"content":{"rendered":"<p>Yesterday I posted <a href=\"http:\/\/www.bartbusschots.ie\/blog\/?p=2306\" target=\"_blank\">my thoughts on watermarking images<\/a> for uploading to the web. This post formed the basis of myself and Allison Sheridan&#8217;s discussions in the <em>Chit Chat Across the Pond<\/em> segment on tonight&#8217;s <a href=\"http:\/\/www.podfeet.com\/\" target=\"_blank\">Nosillacast Mac Podcast<\/a>. During the discussion we talked a little about how I watermark my images, and I realised that I hadn&#8217;t released a version of my image processing scripts <a href=\"http:\/\/www.bartbusschots.ie\/blog\/?p=1048\" target=\"_blank\">since 2008<\/a>! I promised I&#8217;d remedy that, so today, after a little tidying up, I&#8217;m releasing the current snapshot of my scripts under the FreeBSD license.<\/p>\n<p>I&#8217;m not releasing these scripts as a polished software package that&#8217;s ready to use, but rather, as a starting point for anyone who wants to create their own watermarking scripts. If you&#8217;re not prepared to get stuck into the command line and a little Perl (VERY little is needed mind), these scripts are of no use to you!<\/p>\n<p>The scripts rely on the free and open source <a href=\"http:\/\/www.imagemagick.org\/\" target=\"_blank\">ImageMagick<\/a> command line image editing tools, so you&#8217;ll need to install ImageMagick before you get stuck in. If you&#8217;re running OS X, I&#8217;d recommend installing ImageMagick via the free and open source <a href=\"http:\/\/www.macports.org\/\" target=\"_blank\">MacPorts<\/a> package manager.<\/p>\n<p><!--more--><\/p>\n<p style=\"text-align:center\"><a href=\"\/downloads\/WebifyImages-v0.2\"><img decoding=\"async\" alt=\"Download\" src=\"\/downloads\/download.png\" style=\"border:0px solid black\" \/><\/a><\/p>\n<p>All the core functionality provided by the scripts is contained within a single perl package, <code>WebifyImages.pm<\/code>. Any customisations you want to make to the watermarks will need to be made here. The code is well commented, but, unfortunately, it dates back to before my conversion to the <a href=\"http:\/\/shop.oreilly.com\/product\/9780596001735.do\" target=\"_blank\">Perl Best Practices<\/a> religion, so it barfs out an embarrassing number of warnings when run through <a href=\"http:\/\/search.cpan.org\/~thaljef\/Perl-Critic-1.117\/lib\/Perl\/Critic.pm\" target=\"_blank\"><code>perlcritic<\/code><\/a>. I do plan to re-write it some day, and when I do I&#8217;ll be making it object orienting, and ensuring that, like all my recently written code, it passes <code>perlcritic<\/code>.<\/p>\n<p>All command line interactions with the functionality contained within <code>WebifyImages.pm<\/code> is accessed through the perl script <code>webifyFn.pl<\/code>. Once you have the scripts up and running, you should never have to edit this file, it really is just a wrapper. If you add any new functions to <code>WebifyImages.pm<\/code> you&#8217;ll need to be sure to add an entry for them into the <code>$WebifyImages::functions<\/code> hashtable or they won&#8217;t be accessible via <code>webifyFn.pl<\/code>.<\/p>\n<h2>Installing the Scripts<\/h2>\n<p>I haven&#8217;t written an installer script, so you&#8217;ll have to do a little work by hand here. Again, don&#8217;t even bother starting with this until you have ImageMagic installed, and know where on your system the binaries for it are located. If you follow my advice and ImageMagick install via MacPorts, the binaries will be located in <code>\/opt\/local\/bin\/<\/code>. If you want to check where they are located, just run:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwhich mogrify\n<\/pre>\n<p>This should return something like:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nbart-imac:~ bart$ which mogrify\n\/opt\/local\/bin\/mogrify\nbart-imac:~ bart$\n<\/pre>\n<p>This shows that my ImageMagick binaries are indeed in <code>\/opt\/local\/bin\/<\/code>.<\/p>\n<ol>\n<li>Unzip the download package, and copy it&#8217;s contents to a folder of your choice on your system. I recommend something like <code>~\/scripts\/webifyImages\/<\/code> (where <code>~<\/code> is your home directory)<\/li>\n<li>Open the file <code>WebifyImages.pm<\/code> and make the following edits:\n<ol>\n<li>Set the value of <code>$WebifyImages::HOMEDIR<\/code> to the location you extracted the zip to. If you used my suggested installation location, you won&#8217;t need to make any changes here.<\/li>\n<li>Set the value of <code>$WebifyImages::IMAGEMAGICK_BIN<\/code> to the location where your ImageMagick binaries are installed.<\/li>\n<\/ol>\n<\/li>\n<li>Open the file <code>webifyFn.pl<\/code> and edit the <code>use lib<\/code> directive on line 33 so that it contains the absolute path to the folder where <code>WebifyImages.pm<\/code> is located.<\/li>\n<li>If your OS&#8217;s copy of Perl is not located at <code>\/usr\/bin\/perl<\/code>, you&#8217;ll need to edit the first line of both <code>WebifyImages.pm<\/code> and <code>webifyFn.pl<\/code> to reflect the path to your instance of Perl. (this location is the default on OS X and most versions of Linux, so you probably won&#8217;t need to change this)<\/li>\n<\/ol>\n<h2>Customising the Scripts<\/h2>\n<p>The first thing you&#8217;ll want to do is create your own versions of the image files containing the URL that will be stamped on the images. You&#8217;ll need to do two versions of your image file, one on a white background, and one on a black one. I&#8217;ve included the <a href=\"http:\/\/www.pixelmator.com\/\" target=\"_blank\">Pixelmator<\/a> files I used to generate my image files in the <code>dev<\/code> folder inside the archive, if you&#8217;re a Pixelmator user you might find them helpful. Once you&#8217;ve created your own image files and saved them somewhere, update the values of the variables <code>$WebifyImages::URL_ICON_ONWHITE<\/code> and <code>$WebifyImages::URL_ICON_ONBLACK<\/code> in <code>WebifyImages.pm<\/code> with the new file paths.<\/p>\n<p>Once you&#8217;ve done that you&#8217;ll also need to update the URLs in the functions <code>insertUrl()<\/code> and <code>insertSemiTransparentUrl()<\/code> on lines 224 and 236 of <code>WebifyImages.pm<\/code>.<\/p>\n<p>At this stage you&#8217;re ready to start using the scripts, but you may want to do some more customisation.<\/p>\n<p>If you want to change the fonts used by the scripts, you can edit the variables <code>$WebifyImages::SCRIPT_FONT<\/code>, <code>$WebifyImages::SANSSERIF_FONT<\/code>, and <code>$WebifyImages::CAPS_FONT<\/code> in <code>WebifyImages.pm<\/code>.<\/p>\n<p>If you use a license other than C<a href=\"http:\/\/creativecommons.org\/licenses\/by-nc-nd\/3.0\/\" target=\"_blank\">reative Commons Non-Commercial, Non-Derivative, Attribution<\/a>, then you&#8217;ll need to create your own image file to represent that license (or download a different CC icon from the Creative Commons site if you are using a different flavour of CC), and edit the variable <code>$WebifyImages::CC_ICON<\/code> in <code>WebifyImages.pm<\/code> with the path to your image.<\/p>\n<h2>Using The Scripts<\/h2>\n<p>The first thing to make VERY clear is that <strong>THESE SCRIPTS ALTER THE IMAGES THEY ARE APPLIED TO<\/strong>. They are designed to be used on images exported from an image management package like Aperture or Lightroom, and are NOT designed to be used on your master images!<\/p>\n<p>You apply the functionality contained in <code>WebifyImages.pm<\/code> to images by changing to the directory containing the images in the terminal, and then invoking<code> webifyFn.pl<\/code> on those images. To make things easier you probably want to add the folder you installed the scripts into to your path. The webifyFn.pl script is invoked in the following way:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwebifyFn.pl &#x5B;function_name] &#x5B;function_arguments]\n<\/pre>\n<p>To get a list of available functions, and a description of the arguments they expect, run:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nwebifyFn.pl list\n<\/pre>\n<p>That really is all there is to it &#8211; you can just use my scripts as they are (with your basic customisations obviously), or you can tinker and edit to your heart&#8217;s content!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday I posted my thoughts on watermarking images for uploading to the web. This post formed the basis of myself and Allison Sheridan&#8217;s discussions in the Chit Chat Across the Pond segment on tonight&#8217;s Nosillacast Mac Podcast. During the discussion we talked a little about how I watermark my images, and I realised that I [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[12,22,16],"tags":[406,374,268,457,458],"series":[],"class_list":["post-2315","post","type-post","status-publish","format-standard","hentry","category-computers-tech","category-photography","category-programming","tag-commandline","tag-image-processing","tag-scripting","tag-software-release","tag-tutorial"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7t9xK-Bl","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/2315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/comments?post=2315"}],"version-history":[{"count":3,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/2315\/revisions"}],"predecessor-version":[{"id":7804,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/2315\/revisions\/7804"}],"wp:attachment":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/media?parent=2315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/categories?post=2315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/tags?post=2315"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/series?post=2315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}