we purchased Aspose.Total api,we need to convert image file to jpeg format,the following extension file convert to jpeg format and only first page if tiff file have more than one page.
If ((ext.ToLower = “ccitt”) Or (ext.ToLower = “gif”) Or (ext.ToLower = “jpeg”) Or (ext.ToLower = “jpg”) Or (ext.ToLower = “png”) Or (ext.ToLower = “tif”) Or (ext.ToLower = “tiff”) Or (ext.ToLower = “bmp”) Or (ext.ToLower = “emf”) Or (ext.ToLower = “exif”) Or (ext.ToLower = “icon”) Or (ext.ToLower = “wmf”)) Then
I mean if tiff have 5 pages,then only 1st page only convert to jpeg format and also need to pass widht and height of the jpeg file(150X150)
Below code we used for image to pdf format conversion
Dim inputfile As String = “D:\error\support.tiff”
Dim outputfile As String = “D:\error\support.pdf”
Dim imageLicense As Aspose.Imaging.License = New Aspose.Imaging.License()
imageLicense.SetLicense(ConfigurationManager.AppSettings(“AsposeLic”))
Dim pdfLicense As Aspose.Pdf.License = New Aspose.Pdf.License()
pdfLicense.SetLicense(ConfigurationManager.AppSettings(“AsposeLic”))
’ instantiate Document Object
Dim doc As Document = New Document()
’ add a page to pages collection of document
Dim page As Aspose.Pdf.Page = doc.Pages.Add()
’ load the source image file to Stream object
Dim fs As FileStream = New FileStream(inputfile, FileMode.Open, FileAccess.Read)
Dim tmpBytes(fs.Length) As Byte
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length))
Dim mystream As MemoryStream = New MemoryStream(tmpBytes)
’ instantiate BitMap object with loaded image stream
Dim b As Bitmap = New Bitmap(mystream)
’ Set margins so image will fit, etc.
page.PageInfo.Margin.Bottom = 0
page.PageInfo.Margin.Top = 0
page.PageInfo.Margin.Left = 0
page.PageInfo.Margin.Right = 0
page.PageInfo.Height = b.Height
page.PageInfo.Width = b.Width
'page.PageInfo.Height = “21.59”
'page.PageInfo.Width = “27.94”
''page.CropBox = New Aspose.Pdf.Rectangle(0, 0, b.Width, b.Height)
'Create an image object
Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image()
'Add the image into paragraphs collection of the section
page.Paragraphs.Add(image1)
’ set the image file stream
image1.ImageStream = mystream
’ save resultant PDF file
doc.Save(outputfile)
'close memoryStream object
fs.Close()
fs.Dispose()
mystream.Close()
mystream.Dispose()
But need to convert jpeg format only including jpeg file,bcz out put jpeg we specify dimension (150X150)
Regards