Loading...

Converting TIFF pages to PNG/JPG causes strething - help pls

Discussions about image processing in GdPicture.NET using GdPictureImaging.

Converting TIFF pages to PNG/JPG causes strething - help pls

Postby notsure » Tue Jun 14, 2011 8:44 pm

I'm trying to convert a multipage tiff to individual jpg or png files. The codes works for the most part, but the resulting jpgs and png files are stretched. It's like the orientation switched from normal to landscape.

Any ideas ?
notsure
 
Posts: 5
Joined: Fri Jun 03, 2011 8:45 pm

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby Loïc » Mon Jun 20, 2011 11:11 am

Hi,

Please provide needed information to reproduce your problem.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby notsure » Mon Jun 20, 2011 3:18 pm

Thanks Loic.

Here is my code. I did put some debug statements, and for some reason the orientation seems off. It seems like it thinks the vertical height is the horizontal height and vice versa.
Code: Select all
'Read the data is a byte array from the db
Dim result As Byte() = faxQuery.FirstOrDefault.faxImage

'DEBUG: Write out the file exact as it is in the database.  This tiff file shows fine in multiple tiff browsers
Dim oFileStream As System.IO.FileStream
oFileStream = New System.IO.FileStream("C:\\fileio.tif", System.IO.FileMode.Create)
oFileStream.Write(result, 0, result.Length)
oFileStream.Close()

oGdPictureImaging.TiffOpenMultiPageForWrite(True)

'Instantiate from the byte array
Dim SrcTiff As Integer = oGdPictureImaging.CreateGdPictureImageFromByteArray(result)

If SrcTiff <> 0 Then
    Dim PageCount As Integer = oGdPictureImaging.TiffGetPageCount(SrcTiff)
    Dim TiffOutputID As Integer

    For i As Integer = 1 To PageCount
            oGdPictureImaging.TiffSelectPage(SrcTiff, i)
            TiffOutputID = oGdPictureImaging.CreateClonedGdPictureImageI(SrcTiff) 'Even if I comment this out, it doesn't work.
            oGdPictureImaging.SaveAsPNG(TiffOutputID, "C:\\fridayafternoon" + i.ToString + ".tif")
    Next

End If
notsure
 
Posts: 5
Joined: Fri Jun 03, 2011 8:45 pm

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby Loïc » Mon Jun 20, 2011 5:07 pm

Hi,

What do you mean by "I did put some debug statements, and for some reason the orientation seems off." ?

Could you attach input image that reproduce the problem ?

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby notsure » Tue Jun 21, 2011 4:24 pm

HI Loic. I just write out the tiff file to look at it. There is really nothing more to it than that.

These are Faxes that I am trying to process. The weird thing is that the faxes look fine in the fax viewer and other tiff viewers. However the dimensions are off. For example, one fax comes in as 1728 x 1066. I don't get it. These dimensions would indicate an image that is wider than it is high. Which is what the png and jpg from GDPicture show. However in all the tiff viewers the tiffs show fine without the stretching.

Any help would be appreciated.
notsure
 
Posts: 5
Joined: Fri Jun 03, 2011 8:45 pm

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby Loïc » Tue Jun 21, 2011 5:01 pm

OK,

Could you provide an image for testing purpose ?
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby notsure » Tue Jun 21, 2011 6:08 pm

Sure thing. Here is the tiff file and the resulting png file.

Here is the to reproduce the stretching:

Dim test As Integer = oGdPictureImaging.TiffCreateMultiPageFromFile("C:\\TestTiff.TIF")
oGdPictureImaging.TiffSelectPage(test, 1)
oGdPictureImaging.SaveAsPNG(test, "C:\\dummy.png")
Attachments
dummy.png
dummy.png (5.96 KiB) Viewed 239 times
TestTiff.TIF
TestTiff.TIF (6.09 KiB) Viewed 239 times
notsure
 
Posts: 5
Joined: Fri Jun 03, 2011 8:45 pm

Re: Converting TIFF pages to PNG/JPG causes strething - help

Postby Loïc » Sat Jun 25, 2011 1:21 pm

Hi,

The resulting image is correct. Just try to open it with GdViewer and you will see that nothing is stretched.
Input & output image has different vertical & horizontal resolutions. So my guess is you are trying to use a viewer that do not render the image according to the resolution.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to Image Processing

Who is online

Users browsing this forum: No registered users and 0 guests