I'm trying to make use of iipimage in my current research project. I have a
program that currently generates tiled image sets for rather large set of
paper mill images. I would like to use iipimage to show this data to other
participants.
I would rather use libtiff directly to prepare the pyramidal images instead of
adding another pass with imagemagick.
Could you share example code that writes a proper tiled image for iipimage? I
am also interested on how the multiple channels in the images work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree you do not always want to convert whole folders or folder trees,
especially if you have a rather dynamic image set.
I use the ImageMagick Com+ compatible object in c# to generate PTIFS on-the-
fly for IIPImage. If a requested PTIF does not exist, it simply creates it on
the spot. Depending on the performance of your host system this creates a
little delay.
Some sample code:
private bool createPTIFusingMagick(string src_path, string tgt_path)
{
// This 'silent method' uses the ImageMagickObject COM+ compatible component
// to create a PTIF directly. Tested with ImageMagick 6.5.8.-Q8
//
// You need to include a reference to ImagemagickObject.dll in your c# project
// and add a 'using ImageMagickObject;' statement.
ImageMagickObject.MagickImageClass imgo = new
ImageMagickObject.MagickImageClass();
// that is all!
return true; // success
}
catch
{
// conversion did not go - error handling here
return false; // failure
}
}
I also managed to apply the same on-the-fly conversion principle from c# using
VIPS, which is generally faster than Imagemagick, but is not COM+ compaticle
and runs commandline from a shell. So it is less elegant, but faster.
private bool createPTIFusingVIPS(string src_path, string tgt_path)
{
// Uses the VIPS application in a 'silent' commandline to do the conversion.
// VIPS is by far the fastest routine to do this.
// You need to put the VIPS commandline tools (generally in the 'bin' folder
of the package) somewhere (I use e:\vips)
string vips_exepath = @"e:\vips\vips.exe"; // in my particular case points to
the folder "e:\vips"
// we use the ProcessStartInfo class to execute VIPS.EXE
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true; // we do not want to see anything
startInfo.UseShellExecute = false;
//startInfo.WorkingDirectory = ... // optional
startInfo.FileName = command;
startInfo.Arguments = arguments;
startInfo.WindowStyle = ProcessWindowStyle.Hidden; // we do not want to see
anything
int timeOut = 12000; // let's keep it within limits
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit(timeOut);
}
return true; // success
}
catch (Exception e)
{
return false; // failure
}
}
It is really not so complicated!
Hope I copied all the code in the right order. I made a few manual changes
compared to my original code.
All the best,
Hans
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2010-04-22
Thanks for your Help!
This is interesting post, but not exactly what I was looking for.
I'm quite happy to calculate pictures beforehand, but I would like to write
data directly to tiff file. Ie. Instead of image files I have a buffer of
pixels that I'm currently writing out as separate tiles (it wouldn't fit to
memory otherwise). I am seeking to replace this procedure to with something
that would produce a single tiff that could be used with iipimage. Writing
directly would be also better, since I could use a domain specific scaling
method that produces different results from imagemagics/vips.
The problem is that although I know how to make a tile tiff (I think) I have
really no idea how to make pyramidal one.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Then I think you'd better look at the Libtiff documentation. The page http://www.libtiff.org/libtiff.html has
a section called 'Tile-oriented Image I/O' that refers to functions called
TIFFWriteEncodedTile and TIFFWriteRawTile. This sound very much like what you
are looking for.
All the best,
Hans
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could also look at the source code of the tiff-handling section of the
vips library for an example of how to generate a multi-resolution pyramid
tiled tiff.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do you have any suggestion why I'm not able to create multi-resolution pyramid
tiled tiff of a 30GB source Tiff file? I have tried VIPS as well as Image
Magic command line utility, but it did not work.
Thanks,
Tejas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Do you have any suggestion why I'm not able to create multi-resolution
pyramid tiled tiff of a 30GB source Tiff file? I have tried VIPS as well as
Image Magic command line utility, but it did not work.
You will need to use the new bigtiff extensions, which are available in the
latest libtiff4 versions. So, you will need to install this then recompile
both vips and iipsrv.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to reply to the email you sent directly to me, but it's impossible to
send emails to your account. So, here's the reply I tried to send:
The error you are getting is coming from libtiff, not vips. What did you
do to install libtiff4 on your machine? Did you install a local copy in
/usr/local or did you replace the system libtiff libraries?
Which version of libtiff is being linked to when you do
"ldd /usr/bin/vips"?
And can you tell me what the ":,,,,,,8" part at the end of your im_copy
command is?
That's for Linux. For Windows the principle is the same - you will have to
build iipsrv using libtiff4.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your response Ruven. You are right, error was not from vips, it was
because of wrong parameters for tiff. John (vips developer) helped me to solve
this error. I need your help to compile iipsv against libtiff4 on windows.
Moreover, please let me know if you have already built it for windows
(libtiff4).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
I'm trying to make use of iipimage in my current research project. I have a
program that currently generates tiled image sets for rather large set of
paper mill images. I would like to use iipimage to show this data to other
participants.
I would rather use libtiff directly to prepare the pyramidal images instead of
adding another pass with imagemagick.
Could you share example code that writes a proper tiled image for iipimage? I
am also interested on how the multiple channels in the images work.
Hi,
I agree you do not always want to convert whole folders or folder trees,
especially if you have a rather dynamic image set.
I use the ImageMagick Com+ compatible object in c# to generate PTIFS on-the-
fly for IIPImage. If a requested PTIF does not exist, it simply creates it on
the spot. Depending on the performance of your host system this creates a
little delay.
Some sample code:
private bool createPTIFusingMagick(string src_path, string tgt_path)
{
// This 'silent method' uses the ImageMagickObject COM+ compatible component
// to create a PTIF directly. Tested with ImageMagick 6.5.8.-Q8
//
// You need to include a reference to ImagemagickObject.dll in your c# project
// and add a 'using ImageMagickObject;' statement.
ImageMagickObject.MagickImageClass imgo = new
ImageMagickObject.MagickImageClass();
object param = new object { src_path, "-define", "tiff:tile-geometry=256x256",
"-compress", "jpeg", "ptif:" + tgt_path };
try
{
// perform the actual conversion
imgo.Convert(ref param);
// that is all!
return true; // success
}
catch
{
// conversion did not go - error handling here
return false; // failure
}
}
I also managed to apply the same on-the-fly conversion principle from c# using
VIPS, which is generally faster than Imagemagick, but is not COM+ compaticle
and runs commandline from a shell. So it is less elegant, but faster.
private bool createPTIFusingVIPS(string src_path, string tgt_path)
{
// Uses the VIPS application in a 'silent' commandline to do the conversion.
// VIPS is by far the fastest routine to do this.
// You need to put the VIPS commandline tools (generally in the 'bin' folder
of the package) somewhere (I use e:\vips)
string vips_exepath = @"e:\vips\vips.exe"; // in my particular case points to
the folder "e:\vips"
// build command string
string command = System.Convert.ToChar(34).ToString() + vips_exepath +
System.Convert.ToChar(34).ToString();
// build command arguments string
string arguments = @"im_vips2tiff "+sourcePath+"
"+targetPath+":jpeg:75,tile:256x256,pyramid";
// we use the ProcessStartInfo class to execute VIPS.EXE
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true; // we do not want to see anything
startInfo.UseShellExecute = false;
//startInfo.WorkingDirectory = ... // optional
startInfo.FileName = command;
startInfo.Arguments = arguments;
startInfo.WindowStyle = ProcessWindowStyle.Hidden; // we do not want to see
anything
int timeOut = 12000; // let's keep it within limits
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit(timeOut);
}
return true; // success
}
catch (Exception e)
{
return false; // failure
}
}
It is really not so complicated!
Hope I copied all the code in the right order. I made a few manual changes
compared to my original code.
All the best,
Hans
Thanks for your Help!
This is interesting post, but not exactly what I was looking for.
I'm quite happy to calculate pictures beforehand, but I would like to write
data directly to tiff file. Ie. Instead of image files I have a buffer of
pixels that I'm currently writing out as separate tiles (it wouldn't fit to
memory otherwise). I am seeking to replace this procedure to with something
that would produce a single tiff that could be used with iipimage. Writing
directly would be also better, since I could use a domain specific scaling
method that produces different results from imagemagics/vips.
The problem is that although I know how to make a tile tiff (I think) I have
really no idea how to make pyramidal one.
Then I think you'd better look at the Libtiff documentation. The page
http://www.libtiff.org/libtiff.html has
a section called 'Tile-oriented Image I/O' that refers to functions called
TIFFWriteEncodedTile and TIFFWriteRawTile. This sound very much like what you
are looking for.
All the best,
Hans
You could also look at the source code of the tiff-handling section of the
vips library for an example of how to generate a multi-resolution pyramid
tiled tiff.
Hans,
Do you have any suggestion why I'm not able to create multi-resolution pyramid
tiled tiff of a 30GB source Tiff file? I have tried VIPS as well as Image
Magic command line utility, but it did not work.
Thanks,
Tejas
You will need to use the new bigtiff extensions, which are available in the
latest libtiff4 versions. So, you will need to install this then recompile
both vips and iipsrv.
Thanks for your response Ruven.
I was wondering if there is any way to specify bigtiff option in command line
utility.
It's not an "option", you need to install a version of libtiff that can handle
this kind of file size.
Thanks a lot Ruven for quick response again.
Ruven,
Would you help me to rebuild iipsrv against libtiff4 for windows system?
Hi Tgajera,
I tried to reply to the email you sent directly to me, but it's impossible to
send emails to your account. So, here's the reply I tried to send:
And can you tell me what the ":,,,,,,8" part at the end of your im_copy
command is?
That's for Linux. For Windows the principle is the same - you will have to
build iipsrv using libtiff4.
Thanks for your response Ruven. You are right, error was not from vips, it was
because of wrong parameters for tiff. John (vips developer) helped me to solve
this error. I need your help to compile iipsv against libtiff4 on windows.
Moreover, please let me know if you have already built it for windows
(libtiff4).