-   Linux - Newbie (
-   -   "hemera photo image" conversion script (

realbezo 12-19-2011 02:43 PM

"hemera photo image" conversion script
Hello, i am a newbie at bash scripting and i have a question. I have many hpi image files in a directory and want to convert them png images.
I found on internet a perl script for this but it converts just single file and i cannot nor modify it neither pass it input file name and desired output file name for batch processing.
Could someone help me, i have more than tousand hpi image files...
( actually my problem is define 2 variables and pass them to the perl script recursively, it sounds simple but not for me)

the script is below;
#! /usr/bin/perl

use Image::Magick; # AAM IT Solutions LTD,License::AGPLv3
my( $image, $mask, $input, $output, $jpg, $png, $line );
#input:hpi file,output: image file or none to display
$image = Image::Magick->new(magick=>'jpg');
#hpi stores the image in jpg
$mask = Image::Magick->new(magick=>'png');
#hpi stores the mask in png
($input, $output) = ($ARGV[0],$ARGV[1]);
open(I, "$input") || die("Error: Opening input argument.");
while($line = <I>){ $_ .= $line;}
($jpg, $png) = m/^.{32}(.*)(\211PNG.*)$/s;
if ( "$output"){ $image->Write($output);}else{ $image->display();}
and i run it with this command line,

"perl /home/user/path/input.hpi /home/user/path/output.png"
but how can i find filenames in a directory and pass all of the files recursively to this script in order to convert them quicker...

John VV 12-19-2011 03:04 PM

that script uses imagemagick ,so....

have you tried the normal everyday use of imagemagick ?

convert name.hpi name.png
then if that works use the IM bulk "mogrify"

man mogrify

mogrify -format png *.hpi

realbezo 12-20-2011 05:18 PM

Hi, i didn't try it before you offered this simple command for converting hpi images but i tried now and it didn't work, i got this message

mogrify: no decode delegate for this image format `000204_4345_1092_oslp.hpi' @ constitute.c/ReadImage/530.
i think it is because of the structure of hpi image format, it is a special format.
i found a link about it (it is a cached webpage, it doesn't actually exist now, thanks to google)

i just need to repeat my command with all file names in a directory, rather than converting just a single image.
actually my question is not about a specific format, it is about bash scripting. in other words how can i make a list of files in a directory and use them.

"perl /home/user/path/input.hpi /home/user/path/output.png"
i need to change "input.hpi" with every file name and give a related output name instead of "output.png". my question is how can i recursively do it.
thanks in advance

All times are GMT -5. The time now is 08:09 AM.