aboutsummaryrefslogtreecommitdiff
path: root/convert/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'convert/contrib')
-rw-r--r--convert/contrib/Original_Script.scptbin0 -> 20608 bytes
-rw-r--r--convert/contrib/imgconv.rb94
-rw-r--r--convert/contrib/web-gallery105
-rwxr-xr-xconvert/contrib/webgallery-zenity.pl160
-rwxr-xr-xconvert/contrib/webgallery.pl154
5 files changed, 513 insertions, 0 deletions
diff --git a/convert/contrib/Original_Script.scpt b/convert/contrib/Original_Script.scpt
new file mode 100644
index 0000000..5ff3bd5
--- /dev/null
+++ b/convert/contrib/Original_Script.scpt
Binary files differ
diff --git a/convert/contrib/imgconv.rb b/convert/contrib/imgconv.rb
new file mode 100644
index 0000000..676ef42
--- /dev/null
+++ b/convert/contrib/imgconv.rb
@@ -0,0 +1,94 @@
+#!/usr/bin/ruby
+
+require 'fileutils'
+
+if ARGV.size < 2
+ puts "Usage: #$0 source_images gallery_name"
+ exit 1
+end
+
+class Gallery
+
+ CONF = {}
+ CONF[:thumbs] = { :target => 'thumbs', :geom => '120x120', :quality => '60' }
+ CONF[:lq] = { :target => 'lq', :geom => '640x480', :quality => '90' }
+ CONF[:mq] = { :target => 'mq', :geom => '800x600', :quality => '80' }
+
+ def initialize(source_dir = '.', gallery = 'web-gallery')
+ @source_dir = source_dir
+ @gallery = gallery
+ end
+
+ def setup_dirs
+ %w(thumbs lq mq hq zip comments).each do |dir|
+ target = File.join(@gallery, dir)
+
+ if File.exists? target
+ warn "Skipping creation of, #{target}, already exists."
+ next
+ end
+
+ FileUtils.mkdir_p target
+ end
+ end
+
+ def setup_access
+ ht = File.join(@gallery, ".htaccess")
+
+ open(ht, 'w') do |fp|
+ fp.puts "<Files info.txt>"
+ fp.puts " deny from all"
+ fp.puts "</Files>"
+ end
+ end
+
+ def create_comment(num)
+ comment_file = File.join(@gallery, 'comments', "#{num}.txt")
+
+ open(comment_file, 'w') do |fp|
+ fp.puts "<span>image #{num}</span>"
+ end
+ end
+
+ def convert_image(conf, src, num)
+ target = File.join(@gallery, conf[:target], "img-#{num}.jpg")
+
+ cmd = "convert -geometry #{conf[:geom]} -unsharp 1x5 "
+ cmd += "-quality #{conf[:quality]} #{src} #{target}"
+
+ system cmd
+ end
+
+ def build_zip_files
+ puts "Building zip files."
+ system("zip -R #@gallery/zip/mq.zip #@gallery/mq/*.jpg");
+ system("zip -R #@gallery/zip/hq.zip #@gallery/hq/*.jpg");
+ end
+
+ def create
+ setup_dirs
+ setup_access
+
+ num = 1
+
+ Dir["#@source_dir/*.jpg"].sort.each do |src|
+ puts "Working on: #{src}"
+
+ FileUtils.cp(src, File.join(@gallery, 'hq', "img-#{num}.jpg"))
+
+ convert_image(CONF[:thumbs], src, num)
+ convert_image(CONF[:lq], src, num)
+ convert_image(CONF[:mq], src, num)
+
+ create_comment(num)
+
+ num += 1
+ end
+
+ build_zip_files
+ end
+end
+
+gal = Gallery.new ARGV[0], ARGV[1]
+gal.create
+
diff --git a/convert/contrib/web-gallery b/convert/contrib/web-gallery
new file mode 100644
index 0000000..952f8fe
--- /dev/null
+++ b/convert/contrib/web-gallery
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+# Nautilus script to generate image galleries for use with original
+# uses Gnome's zenity for user dialogs
+# uses ImageMagick's convert
+# (c) 2005 boris de laage <bdelaage@free.fr>
+# based on imgconv bu Jakub Steiner
+
+set -e
+
+name=`basename $0`
+
+# convert options
+convertor=`which convert`
+extra_ops="-strip"
+
+#default options
+dir=./web-gallery
+
+files=$(echo $@ | sed 's/ /\n/g' | sort)
+numfiles=$#
+
+if [ -z $convertor ]; then
+ zenity --title $name --error --error-text "convert not found !"
+ exit 1
+fi
+
+if [ $numfiles == 0 ]; then
+ zenity --title $name --error --error-text "No input files !"
+ exit 1
+fi
+
+#progressbar stuff
+steps=5
+increment=`expr 100 / \( $numfiles \* $steps \) `
+progress=0
+
+
+mkdir -p $dir/thumbs
+mkdir -p $dir/lq
+mkdir -p $dir/mq
+mkdir -p $dir/hq
+mkdir -p $dir/zip
+mkdir -p $dir/comments
+chmod o+w $dir/comments
+
+echo "<Files info.txt>" > $dir/.htaccess
+echo " deny from all" >> $dir/.htaccess
+echo "</Files>" >> $dir/.htaccess
+
+
+i=1
+
+for imagefile in $files
+ do
+ process="converting $imagefile"
+
+ # Thumbnail
+ echo "#$process : thumbnail"
+ $convertor -geometry 120x120 -modulate 100,140,100 -unsharp 1x20 \
+ -quality 60 $extra_opts $imagefile $dir/thumbs/img-$i.jpg
+ progress=`expr $progress + $increment`
+ echo $progress
+
+ # LQ
+ echo "#$process : lq"
+ $convertor -geometry 640x480 -modulate 100,130,100 -unsharp 1x5 \
+ -quality 90 $imagefile $dir/lq/img-$i.jpg
+ progress=`expr $progress + $increment`
+ echo $progress
+
+ # MQ
+ echo "#$process : mq"
+ $convertor -geometry 1024x768 -modulate 100,130,100 -unsharp 1x5 \
+ -quality 80 $imagefile $dir/mq/img-$i.jpg
+ progress=`expr $progress + $increment`
+ echo $progress
+
+ # HQ
+ echo "#$process : hq"
+ cp $imagefile $dir/hq/img-$i.jpg
+ progress=`expr $progress + $increment`
+ echo $progress
+
+ # Comments
+ echo "#$process : comments"
+ # template for comment
+ echo "<span>Photo $i</span> " > $dir/comments/$i.txt
+ progress=`expr $progress + $increment`
+ echo $progress
+
+ i=`expr $i + 1`
+
+done | zenity --progress --title="Scaling images, please wait..." --auto-close
+
+
+(
+ echo "1"
+ echo "#Making archives"
+ zip -R $dir/zip/mq.zip web-gallery/mq/*.jpg
+ zip -R $dir/zip/hq.zip web-gallery/hq/*.jpg
+ echo "100"
+) | zenity --progress --pulsate --auto-close --title="Zipping images"
+
+zenity --title $name --info --info-text "Your <b>O.R.I.G.I.N.A.L</b> gallery is ready."
diff --git a/convert/contrib/webgallery-zenity.pl b/convert/contrib/webgallery-zenity.pl
new file mode 100755
index 0000000..7f06826
--- /dev/null
+++ b/convert/contrib/webgallery-zenity.pl
@@ -0,0 +1,160 @@
+#!/usr/bin/perl -w
+
+# little script to generate image galleries for use with original PHP backend
+# uses Gnome's zenity for user dialogs
+# uses gdk-pixbuf-convert if available, otherwise convert (from ImageMagick)
+# (c) 2003-2004 Jakub 'jimmac' Steiner, (c) 2003-2004 Colin Marquardt
+# based on webgallery.pl by Tuomas Kuosmanen
+
+use strict;
+use warnings;
+use FileHandle;
+
+my $num_of_args = scalar @ARGV;
+
+if (!@ARGV or ($num_of_args == 0)) {
+ exec("zenity --error --title \"\" --text \"No args\n\nYou have to select images to work on.\"");
+ exit;
+}
+
+my $GdkPixbufConvert = "gdk-pixbuf-convert";
+my $Convert = "convert";
+my $dir = "web-gallery";
+
+
+# try to find a scaler program
+my $scaler;
+$scaler = `which $GdkPixbufConvert`;
+if ($scaler eq "") {
+ $scaler = `which $Convert`;
+}
+if ($scaler eq "") {
+ exec("zenity --error --title \"\" --text \"No scaling program\n\nYou need to have '$GdkPixbufConvert' or '$Convert' available.\"");
+ exit;
+}
+chomp $scaler;
+
+my @args = sort(@ARGV);
+my $NumOfIncrements = 5; # 5 increments per file (as we are
+ # expecting to create 5 files for each
+ # image)
+my $increment = 100 / ($num_of_args * $NumOfIncrements);
+my $progress=0;
+my $reply="";
+
+sub make_dirs {
+ my $ErrMsg;
+ unless (-d "$dir") {
+ mkdir("./$dir") or
+ $ErrMsg .= "Could not create './$dir'!\n";
+ }
+ unless (-d "$dir/thumbs") {
+ mkdir("./$dir/thumbs") or
+ $ErrMsg .= "Could not create './$dir/thumbs'!\n";
+ }
+ unless (-d "$dir/lq") {
+ mkdir("./$dir/lq") or
+ $ErrMsg .= "Could not create './$dir/lq'!\n";
+ }
+ unless (-d "$dir/mq") {
+ mkdir("./$dir/mq") or
+ $ErrMsg .= "Could not create './$dir/mq'!\n";
+ }
+ unless (-d "$dir/hq") {
+ mkdir("./$dir/hq") or
+ $ErrMsg .= "Could not create './$dir/hq'!\n";
+ }
+ unless (-d "$dir/comments") {
+ mkdir("./$dir/comments") or
+ $ErrMsg .= "Could not create './$dir/comments'!\n";
+ }
+ unless (-d "$dir/zip") {
+ mkdir("./$dir/zip") or
+ $ErrMsg .= "Could not create './$dir/zip'!\n";
+ }
+ if ($ErrMsg ne "") {
+ exec("zenity --error --title \"Giving Up\" --text \"Fatal Error\n\n$ErrMsg\"");
+ die "Errors occurred:\n$ErrMsg";
+ }
+}
+make_dirs();
+
+# ------------------------------------------------------------------------
+open(PROGRESS,"| zenity --progress --auto-close --title=\"\" \\
+ --text=\"Scaling images, please wait\"");
+PROGRESS->autoflush(1);
+
+my $i=1;
+my $SetDirDate = 0;
+foreach my $arg (@args) {
+ if (-d $arg) { # argument is a directory, skip it
+ $progress += ($increment * $NumOfIncrements);
+ print PROGRESS "$progress\n";
+ next;
+ }
+ my $FileType = `file "$arg"`;
+ unless ($FileType =~ /image data/i) { # check for valid file type
+ # maybe check for JPEG and PNG explicitly?
+ #print $FileType;
+ $progress += ($increment * $NumOfIncrements);
+ print PROGRESS "$progress\n";
+ next;
+ }
+ if ($SetDirDate == 0) { # we are looking at the first image
+ $SetDirDate = (stat $arg)[9]; # get mtime
+ if ($SetDirDate > 0) {
+ # (can also return -1 if strange mtime, don't use this
+ # time stamp then)
+ # set mtime of gallery directory to the one of the first
+ # image file:
+ $reply .= `touch -r "$arg" $dir`;
+ print "Setting mtime of $dir to $SetDirDate\n";
+ } else {
+ # give it another try the next time around:
+ $SetDirDate = 0;
+ }
+ }
+ # thumbnails
+ $reply .= `$scaler -geometry 120x120 -quality 60 "$arg" $dir/thumbs/img-$i\.jpg 2>&1`;
+ $progress += $increment;
+ print PROGRESS "$progress\n";
+ # LQ size
+ $reply .= `$scaler -geometry 640x480 -quality 75 "$arg" $dir/lq/img-$i\.jpg 2>&1`;
+ $progress += $increment;
+ print PROGRESS "$progress\n";
+ # MQ size
+ $reply .= `$scaler -geometry 800x600 -quality 75 "$arg" $dir/mq/img-$i\.jpg 2>&1`;
+ $progress += $increment;
+ print PROGRESS "$progress\n";
+ # HQ size (just copy the original)
+ $reply .= `cp "$arg" $dir/hq/img-$i\.jpg 2>&1`;
+ $progress += $increment;
+ print PROGRESS "$progress\n";
+ # comment
+ open(COMM, ">$dir/comments/$i\.txt");
+ print(COMM "<span>image $i</span>\n");
+ close(COMM);
+ $progress += $increment;
+ print PROGRESS "$progress\n";
+ $i++;
+
+ # an error occurred:
+ if ($reply ne "") {
+ print PROGRESS "100\n";
+ close(PROGRESS);
+ exec("zenity --error --title \"\" --text \"Fatal Error\n\n$reply\"");
+ die("Error while scaling");
+ }
+}
+print PROGRESS "100\n";
+close(PROGRESS);
+
+# ------------------------------------------------------------------------
+open(PROGRESS, "| zenity --progress --pulsate --auto-close \\
+--title \"\" --text \"Zipping images\"");
+PROGRESS->autoflush(1);
+print PROGRESS "1";
+system("zip -R $dir/zip/mq.zip $dir/mq/*.jpg");
+system("zip -R $dir/zip/hq.zip $dir/hq/*.jpg");
+print PROGRESS "100\n";
+close(PROGRESS);
diff --git a/convert/contrib/webgallery.pl b/convert/contrib/webgallery.pl
new file mode 100755
index 0000000..d8a7ce7
--- /dev/null
+++ b/convert/contrib/webgallery.pl
@@ -0,0 +1,154 @@
+#!/usr/bin/perl -w
+#
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# #
+# Web Gallery script for Nautilus - Depends on "original" web backend #
+# for displaying the gallery. #
+# #
+# Written in perl because I suck more with sh scripting. #
+# Also needs gnome-utils for gdialog. #
+# #
+# Hacked together by Tuomas Kuosmanen <tigert@ximian.com> #
+# Tweaked to use NetPBM by Jakub Steiner <jimmac@ximian.com> #
+# Released under the GPL license. #
+# #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+die "No files to convert" unless @ARGV;
+
+use Gtk;
+init Gtk;
+
+@files = sort(@ARGV);
+
+my $dir = "web-gallery";
+
+sub make_dirs {
+
+ unless (-d "$dir") {
+ mkdir("./$dir") or die "Aargh.\n";
+ }
+ unless (-d "$dir/thumbs") {
+ mkdir("./$dir/thumbs") or die "Aargh.\n";
+ }
+ unless (-d "$dir/lq") {
+ mkdir("./$dir/lq") or die "Aargh.\n";
+ }
+ unless (-d "$dir/mq") {
+ mkdir("./$dir/mq") or die "Aargh.\n";
+ }
+ unless (-d "$dir/hq") {
+ mkdir("./$dir/hq") or die "Aargh.\n";
+ }
+ unless (-d "$dir/comments") {
+ mkdir("./$dir/comments") or die "Aargh.\n";
+ }
+}
+
+sub make_gallery_fake {
+ my $foo = shift;
+ print ("PARAM: $foo\n");
+ sleep 1;
+}
+
+
+$w = new Gtk::Window;
+$label = new Gtk::Label(' Web Gallery generation in progress... ');
+$pbar = new Gtk::ProgressBar;
+$vb = new Gtk::VBox(0, 0);
+$b = new Gtk::Button('Cancel');
+$w->add($vb);
+$vb->add($label);
+$vb->add($pbar);
+$vb->add($b);
+
+$b->signal_connect('clicked', sub {Gtk->exit(0)});
+$w->signal_connect('destroy', sub {Gtk->exit(0)});
+
+$w->show_all();
+$i = 0;
+$pbar->update($i);
+
+@files = sort(@ARGV);
+$num_of_files = scalar @files;
+$increment = 1 / ( 5 * $num_of_files );
+$i = 1;
+$progress = 0;
+
+make_dirs();
+#read nautilus metafile if available
+open(METAXML, "./.nautilus-metafile.xml") or print("no metafile");
+@meta_xml = <METAXML>;
+close(METAXML);
+
+
+foreach $file (@files) {
+
+ $pbar->update($progress);
+ $pbar->set_show_text(1);
+ $pbar->set_format_string("$i of $num_of_files");
+ $progress += $increment;
+ while (Gtk->events_pending) {
+ Gtk->main_iteration;
+ }
+
+ # do the stuff, collect error messages to a variable.
+ #$reply=`convert -geometry 120x120 -colors 64 -dither $file $dir/thumbs/img-$i\.png 2>&1`;
+ $reply=`convert -geometry 120x120 $file $dir/thumbs/img-$i\.jpg 2>&1`;
+ #$reply =`jpegtopnm $file | pnmscale -xysize 120 120 | ppmquant -floyd 16 | pnmtopng -interlace -compression 9 > $dir/thumbs/img-$i\.png 2>&1`;
+
+ $pbar->update($progress);
+ $progress += $increment;
+ while (Gtk->events_pending) {
+ Gtk->main_iteration;
+ }
+
+ $reply = $reply . `convert -geometry 640x640 $file $dir/lq/img-$i.jpg 2>&1`;
+ #$reply = $reply . `jpegtopnm $file | pnmscale -xysize 640 640 | ppmtojpeg --quality 80 --progressive > $dir/lq/img-$i.jpg 2>&1`;
+
+ $pbar->update($progress);
+ $progress += $increment;
+ while (Gtk->events_pending) {
+ Gtk->main_iteration;
+ }
+
+ $reply = $reply . `convert -geometry 800x800 $file $dir/mq/img-$i.jpg 2>&1`;
+ #$reply = $reply . `jpegtopnm $file | pnmscale -xysize 800 800 | ppmtojpeg --quality 80 --progressive > $dir/mq/img-$i.jpg 2>&1`;
+
+ $pbar->update($progress);
+ $progress += $increment;
+ while (Gtk->events_pending) {
+ Gtk->main_iteration;
+ }
+
+ $reply = $reply . `cp $file $dir/hq/img-$i.jpg 2>&1`;
+
+ $pbar->update($progress);
+ $progress += $increment;
+ while (Gtk->events_pending) {
+ Gtk->main_iteration;
+ }
+
+ # comment
+ open (COMM, ">$dir/comments/$i\.txt");
+ print(COMM "<span>image $i: </span>\n");
+ #check for comments in the metafile
+ #maybe using a proper XML parser would make sense in future
+ foreach $radek (@meta_xml) {
+ chomp($radek);
+ if ($radek =~ m/.*name="([^"]*)".*annotation="([^"]*).*"/) {
+ if ($1 eq $file) {
+ print(COMM "<span>$2</span>\n");
+ }
+ }
+ }
+ close(COMM);
+
+ $i++;
+
+ # print possible error messages
+ if ($reply ne "") {
+ print("There was an error message: $reply\n");
+ }
+}
+