#!/usr/bin/perl -w # creates a Open Office Impress presentation from a list of images # and keeps their aspect ratio while maximizing their size on the slides # Copyright (C) 2005 Karl-Heinz Herrmann # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . use OpenOffice::OODoc; use Image::Size; if ((@ARGV <1) or (@ARGV > 2)){ print << "EOF"; Usage: img2ooImpress.pl ImageFileList [outputfile.odp] ImageFileList is a file containing all images to import EOF exit; } my $outputfile; my $imgFileList=shift; $outputfile="img2ooImpressExport.odp" unless $outputfile=shift; open (IN,"<$imgFileList") or die "Can't read $imgFileList\n"; my $document = ooDocument ( file => $outputfile, create => 'presentation', member => 'content' ); $document->createImageStyle("slide"); my $i=1; while (my $imgfile=){ chomp($imgfile); my $test= $document->appendElement ('//office:presentation',0,'draw:page'); # print "append-element return: $test\n"; ($xdim,$ydim)=imgsize("$imgfile"); if ($xdim<$ydim){ # Hochformat print "Image $imgfile has size $xdim,$ydim\n"; $yslidesize=18; $xslidesize=$yslidesize/$ydim*$xdim; my $image= $document->createImageElement ( "Slide".$i, description => "image ".$i." filename:".$imgfile, page => $test, position => "0.5cm,2cm", import => $imgfile, size => "${xslidesize}cm,${yslidesize}cm", style => "slide" ); }else{ print "Image $imgfile has size $xdim,$ydim\n"; $xslidesize=18; $yslidesize=$xslidesize/$xdim*$ydim; my $image= $document->createImageElement ( "Slide".$i, description => "image ".$i." filename:".$imgfile, page => $test, position => "1.5cm,3cm", import => $imgfile, size => "${xslidesize}cm,${yslidesize}cm", style => "slide" ); } # print "create image return: $image\n"; $i++; } $document->save;