Part of the image gets cut in the converted Image


#1

Hi,

We are having an issue with Aspose.Email . We have been using Aspose.Email 19.6 for conversion of email file to tiff image. Our images in email are getting cut off in the converted image.

Please find the attachment for the sample file and the converted image.
Please help us out.
SampleFile.zip (260.2 KB)


#2

@52000537,

Can you please share source code so that we may further investigate to help you out.


#3

Please find the sample code in the attachment. And let us know for any fix.
EmailTest-SampleCode.zip (11.9 KB)

Thanks You


#4

@52000537,

I have investigated this issue on my end and an issue with ID EMAILNET-39549 has been created 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 notified once the issue will be fixed.


#5

Thank you @Adnan.Ahmad

We are looking for update on this .
Is it possible to get any code workaround for this issue ?

Thanks.


#6

@52000537,

I regret to share that the issue has just recently been created in our issue tracking system and is pending for investigation and resolution. We will be able to share updates with you as soon as the issue will be scheduled for investigation and resolution on its due turn.


#7

Thank You @mudassir.fayyaz

Is there any update on this ?
Can we expect any code workaround for this issue ?

Thanks.


#8

@52000537,

I like to inform that we have investigated issue on our end in detail. This is not bug of Aspose.Email. Aspose.Email API in sample project used to get html body with image and this task performed correctly. Than you are trying to convert this html file to tiff file by Aspose.Words, but in tiff file image is cut off, so this bug of Aspose.Word and can be fixed only Aspose.Word team. Please check attachment.Test Sample File.zip (18.8 KB)


#9

Thank You @Adnan.Ahmad

Can this ticket be shared with Aspose.Word team and taken forward to get the issue resolved ?
Please suggest regarding this issue since some days are passed from when we reported the issue.

Thanks.


#10

@52000537,

I have moved this thread to Aspose.Words forum. Our colleague from Aspose.Words will help you out in this issue.


#11

Thank You @Adnan.Ahmad

Aspose Words Team ,

can you please review the issue and let us know the details ?


#12

@52000537

The MHTML file generated by Aspose.Email has image with large size that does not fit on the default page size. You need to resize it according to page size. Please use the following code example to get the desired output.

Document doc = new Document(MyDir + "input.mhtml");
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
    ResizeLargeImage(shape);
doc.Save(MyDir + "19.8.tiff");

public static void ResizeLargeImage(Shape image)
{
    // Return if this shape is not an image.
    if (!image.HasImage)
        return;

    // Calculate the free space based on an inline or floating image. If inline we must take the page margins into account.
    PageSetup ps = image.ParentParagraph.ParentSection.PageSetup;
    double freePageWidth = image.IsInline ? ps.PageWidth - ps.LeftMargin - ps.RightMargin : ps.PageWidth;
    double freePageHeight = image.IsInline ? ps.PageHeight - ps.TopMargin - ps.BottomMargin : ps.PageHeight;


    ImageSize size = image.ImageData.ImageSize;
    Boolean exceedsMaxPageSize = size.WidthPoints > freePageWidth || size.HeightPoints > freePageHeight
        || image.Width > freePageWidth || image.Height > freePageHeight;

    if (exceedsMaxPageSize)
    {
        // Calculate the ratio to fit the page size based on which side is longer.
        Boolean widthLonger = (size.WidthPoints > size.HeightPoints);
        double ratio = widthLonger ? freePageWidth / size.WidthPoints : freePageHeight / size.HeightPoints;

        if (ratio > .90)
            ratio = ratio - .10;
        // Set the new size.
        image.Width = size.WidthPoints * ratio;
        image.Height = size.HeightPoints * ratio;
    }
}