webOS Nation Forums >  Homebrew >  TouchPad Patches > ImageMagick BASH script for TouchPad-friendly center tiling
ImageMagick BASH script for TouchPad-friendly center tiling
  Reply
Like Tree1Likes
  • 1 Post By limnion

 
Thread Tools Display Modes
Old 02/24/2013, 03:40 PM   #1 (permalink)
Member
 
limnion's Avatar
 
Posts: 4
So, I was a little bit bummed when I found out that my TouchPad didn't have fancy options for scaling or tiling wallpaper, so I wrote a set of simple BASH scripts that perform various batch operations on images to make them more TouchPad-friendly. This one center-tiles smaller images across a 1024x1024 canvas. It's not perfect, but this is the least buggy of the bunch. Here goes:

Code:
#!/bin/bash

if [ ! -d ./tiled ]
	then
		mkdir ./tiled
fi

for file in ./*.*
do
	if [ $file != $0 ]
		then
			imgw=`convert $file -format "%[fx:w]" info:`
			imgh=`convert $file -format "%[fx:h]" info:`
			xo=$((0-((1024-$imgw)/2-$imgw)))
			yo=$((0-((1024-$imgh)/2-$imgh)))
			echo Tiling $file...
			convert $file \( -clone 0 \) +append -write mpr:sometile +delete -size 1024x1024 -tile-offset +$xo+$yo tile:mpr:sometile tiled/$file
	fi
done
The processed file is placed in ../tiled because I didn't write anything in to compensate for the presence of anything other than the script and unprocessed images in the working directory. Truth be told, this is very kludgy code, but it gets the job done for the most part. Hopefully someone finds it useful. Example output made from a scaled down photo of some canned oysters is appended below.

Edit: So, for some reason smaller images and some PNGs don't tile correctly. From what I can tell, it's an ImageMagick problem, so I'm not sure what I can do about it.

Edit 2: Now tiled images are placed in a subdirectory called tiled. Will still freak out if there are non-image files in the directory, but directories and files without an extension won't freak it out anymore.
Attached Images
File Type: jpg 20110511_001.JPG (314.5 KB, 11 views) Email Attachment

Last edited by limnion; 02/24/2013 at 08:02 PM. Reason: Fixed directory and wildcard issues
limnion is offline   Reply With Quote
Liked by HelloNNNewman likes this.
Thanked By: HelloNNNewman
Old 02/24/2013, 03:49 PM   #2 (permalink)
 
HelloNNNewman's Avatar
 
Posts: 15,882


(to proper forum)
__________________



Network Moderator | Mobile Nations Rules
HelloNNNewman is offline   Reply With Quote
Thanked By: limnion
Reply

 

Tags
bash, imagemagick, wallpaper

Thread Tools
Display Modes



 


Content Relevant URLs by vBSEO 3.6.0