Tiff to jpeg -Image quality was less


#1

Hi,


Here i converted tiff image into image .but i am getting image quality was poor,also attached the image that were converted online seems good .


using (var multiImage = (TiffImage)Image.Load(inputFilePath))
{
height = 70;
width = 49;
multiImage.Resize(width, height);
var obj = new JpegOptions{ResolutionSettings = new ResolutionSetting()};
obj.ResolutionSettings.VerticalResolution = 300;
obj.ResolutionSettings.HorizontalResolution = 300;
if (obj.ExifData == null)
{
obj.ExifData = new global::Aspose.Imaging.Exif.JpegExifData();
}

var copiedFrame = TiffFrame.CopyFrame(multiImage.Frames[0]);
var toSaveTiff = new TiffImage(copiedFrame);
toSaveTiff.Save(outputFile + “\” + filename + “.jpg”, obj);
toSaveTiff.Dispose();
}
multiImage.Dispose();

#2

Hi Aravind,

I have observed the requirement shared by you and request you to please share the source TIFF file for further investigation on our end. Please also share that which version of Aspose.Imaging you are using on your end to reproduce the issue.

Many Thanks,


#3

Here i have attched the sample.

Kindly make priority to this ,as it was urgent.

Thanks
Aravind.A

#4

Hi Aravind,

I have worked with the TIFF file shared by you and have been able to observe the issue of low quality JPEG. An issue with ID IMAGINGNET-2299 has been created as enhancement request in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed

For the time being, I suggest you to use following alternative in your sample code as it generated slightly better result on my end.

multiImage.Resize(width, height, ResizeType.LanczosResample);

Many Thanks,

#5

FYI


If i converted Tiff image to pdf ,and then converting pdf to jpeg ,the excepted quality was coming.


var pdf = new Pdf();
var fs = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read);
var tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));
var mystream = new MemoryStream(tmpBytes);
var b = new Bitmap(mystream);
var sec = new Section(pdf);
sec.PageInfo.Margin.Top = 5;
sec.PageInfo.Margin.Bottom = 5;
sec.PageInfo.Margin.Left = 5;
sec.PageInfo.Margin.Right = 5;
sec.PageInfo.PageWidth = (b.Width / b.HorizontalResolution) * 72;
sec.PageInfo.PageHeight = (b.Height / b.VerticalResolution) * 72;
pdf.Sections.Add(sec);
var image = new ImagePDF(sec);
sec.Paragraphs.Add(image);
image.ImageInfo.ImageFileType = ImageFileType.Tiff;
image.ImageInfo.ImageStream = mystream;
image.ImageScale = 0.95F;


/////////////////////////////////////////////////////////////////////////////
var pdfDocument = new doc(pdf);
var pageCollection = pdfDocument.Pages;

//Sets PAGE-INDEX
int c = 0;
for (var pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
var pdfPage = pageCollection[pageCount];
using (var imageStream = new FileStream(outputFilePath, FileMode.Create))
{
var resolution = new Resolution(100);
JpegDevice JpegDevice;
if (argModel.imgToScale != null || argModel.imageToScaleHeight != null || argModel.imageToScaleWidth != null)
{
JpegDevice = argModel.imgToScale != null ? new JpegDevice((int)argModel.imgToScale, (int)argModel.imgToScale, resolution) : new JpegDevice((int)argModel.imageToScaleWidth, (int)argModel.imageToScaleHeight, resolution);
}
else
{
JpegDevice = new JpegDevice(Convert.ToInt32(pdfPage.ArtBox.Width), Convert.ToInt32(pdfPage.ArtBox.Height), resolution);
}
JpegDevice.Process(pdfDocument.Pages[pageCount], imageStream);
imageStream.Close();
c++;
}
}


Thanks in advance
Arvaind.A


#6

Hi Aravind,

Thank you for sharing the additional information. I have appended the shared information in associated issue and will share the feedback with you as soon as it will be shared by our product team.

Many Thanks,


#7

@ARAVINDDSRC,

I suggest you to please try using following sample code on your end.

public static void TestTiff()
{
    String path = "C:\\Aspose Data\\";
    String fileName = "MultiTIF.tif";
    String inputFilePath = path + fileName;
    using (var multiImage = (TiffImage)Image.Load(inputFilePath))
    {
	
	    int height = 70;
	    int width = 49;

	    multiImage.Resize(width, height,ResizeType.HighQualityResample)

	    var obj = new JpegOptions { ResolutionSettings = new ResolutionSetting() };

	    obj.ResolutionSettings.VerticalResolution = 300;
	    obj.ResolutionSettings.HorizontalResolution = 300;

	    if (obj.ExifData == null)
	    {
		    obj.ExifData = new global::Aspose.Imaging.Exif.JpegExifData();
	    }

	    var copiedFrame = TiffFrame.CopyFrame(multiImage.Frames[0]);
	    var toSaveTiff = new TiffImage(copiedFrame);
	    toSaveTiff.Save(path + fileName + "HQ.jpg", obj);
	    toSaveTiff.Dispose();

    }           
}

Many Thanks,

Mudassir Fayyaz


#8

The issues you have found earlier (filed as IMAGINGNET-2299) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz


#9

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.