LEADTOOLS Support
Imaging
Imaging SDK Questions
Converting Tiff Images to different Resolution
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Saturday, June 17, 2006 1:38:35 PM(UTC)
Groups: Registered
Posts: 14
We have a large number of TIF images where XResolution and YResolution are 100. Image Height = 2376 and Image Width = 1600. The implication is that the image is 16 inches by 24 inches. I would like to modify the resolution to 300x300 and retain height and width settings. This would yield an image sized ~5 inches by 8 inches.
I have tried calling L_LoadFile(), modifying fileInfo.XResolution and fileInfo.YResolution, and calling L_FileConvert(). Checking the FileInfo fields for the resulting file still yields 100x100.
Can someone provide an effective solution?
#2
Posted
:
Sunday, June 18, 2006 12:11:02 PM(UTC)
Groups: Registered
Posts: 14
Hi Folks,
I have also been trying to solve this problem using
L_SizeBitmap( &bmh, bmh.Width / 2, bmh.Height / 2, SIZE_NORMAL );
L_SaveFile( (char *)strOutput.c_str(), &bmh, fileInfo.Format, bmh.BitsPerPixel, 0, SAVEFILE_MULTIPAGE, NULL, NULL, NULL );
The code seems to execute without error but the resulting image is blank. The image size appears to be as expected. Also, there are two (blank) pages in the output image.
I'm still looking for a solution that makes the original, large image look like a regular size image.
#3
Posted
:
Tuesday, June 20, 2006 11:17:34 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
What you need to do is load, modify the resolution values in the LEAD Bitmap Handle itself, then save. The code will look like this:
L_Load...(.., &bmh, ..);
bmh.XResolution = 300;
bmh.YResolution = 300;
L_Save...(.., &bmh, ..);
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#4
Posted
:
Monday, June 26, 2006 9:51:16 PM(UTC)
Groups: Registered
Posts: 3
I have the same issue, I'm using leadTools 14.5. Any sample vb.net will be appreciated.
Thanks
Praveen B
#5
Posted
:
Monday, June 26, 2006 10:25:51 PM(UTC)
Groups: Registered
Posts: 3
Hello,
I'm a newbie to LeadTools. I need to convert my Tiff images from the RightFax which are of low resolution to 400 dpi Tiff Images.
I'm able to convert to 400 dpi Tiff Images but the height and width of the converted tiff image is half the size of the original image. Why is this so.
Can you be able to provide me with vb.net sample code.
Thanks / Regards
Praveen B
#6
Posted
:
Wednesday, June 28, 2006 10:41:49 AM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
Praveen,
If you want to change the resolution and maintain the same physical size (in inches), you must also change the pixel size of the image.
If you are using our .NET classes, in addition to changing the resolution, you must also use the SizeCommand class.
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#7
Posted
:
Thursday, June 29, 2006 1:01:39 AM(UTC)
Groups: Registered
Posts: 3
Amin,
Thanks for your response. I'm still unable to fix the Height and Width (inches) of the newly converted image after using the SizeCommand Class.
Here is the sample code
imageInfo1 = codecs1.GetInformation(strFileName,
True)
tempImage1 = codecs1.Load(strFileName)
command =
New SizeCommand
command.Flags = RasterSizeFlags.Normal
command.Width = imageInfo1.Width
command.Height = imageInfo1.Height
command.Run(tempImage1)
tempImage1.XResolution = intConvertResolution
tempImage1.YResolution = intConvertResolution
codecs1.Save(tempImage1, strDestDirectory & tempFileInfo.Name, RasterImageFormat.TifCcittGroup4, tempImage1.BitsPerPixel, 1, tempImage1.PageCount, 1, CodecsSavePageMode.Overwrite)
Any sample will be appreciated.
Thanks
Praveen B
#8
Posted
:
Thursday, June 29, 2006 2:25:02 PM(UTC)
Groups: Manager, Tech Support
Posts: 367
Was thanked: 1 time(s) in 1 post(s)
Praveen,
You code seems to be setting command.Width and command.Height to the original values of the image itself. This means you are not resizing and the command does nothing.
If you change resolution by a certain ratio, you need to change the width and height by same ratio. For example, if you double the resolution, you should also double the width and height.
This way, the physical size will remain the same.
Amin Dodin
Senior Support Engineer
LEAD Technologies, Inc.
#9
Posted
:
Tuesday, March 13, 2007 8:59:48 AM(UTC)
Groups: Registered
Posts: 2
I have this working for the first page of a multi-page Tif, but the 2nd and 3rd pages do not get converted. That is, when I convert a 200dpi image to a 300dpi, only the first page is converted correctly. The rest of the pages in the multi-page tiff do not get converted and remain at 200dpi. This is the code i'm using, what do I need to change?
decimal iPercentChangeX = Convert.ToDecimal(iResolution) / Convert.ToDecimal(iOrigXResolution);
decimal iPercentChangeY = Convert.ToDecimal(iResolution) / Convert.ToDecimal(iOrigYResolution);
SizeCommand command = new SizeCommand();
command.Flags = RasterSizeFlags.Normal;
command.Width = Convert.ToInt32(LTImage.Width * iPercentChangeX);
command.Height = Convert.ToInt32(LTImage.Height * iPercentChangeY);
command.Run(LTImage);
LTImage.XResolution = iXResolution;
LTImage.YResolution = iYResolution;
Do I need to loop through all the pages in LTImage? If so, how?
Thanks.
#10
Posted
:
Wednesday, March 14, 2007 5:52:43 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 764
Yes, you will need to loop and resize for each page. All you need to change is the Page property of the RasterImage class and then run your SizeCommand again.
LTImage.Page = LTImage.Page + 1
LEADTOOLS Support
Imaging
Imaging SDK Questions
Converting Tiff Images to different Resolution
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.