Free Support Forum - aspose.com

Multipage TIFF has less size after it's stamped

Hello,

I hit the situation that my multipage tiff file’s size becomes less when I put a stamp (text or image) on it using aspose-imaging.
But when I do stamping on one-page tiff it’s size becomes bigger.
Is it possible to do something to avoid size decreasing while stamping multipage tiff?
Thank you in advance.

multipage_tiff_examples.zip (1.7 MB)

@paultomsky

Can you please share the desired output PDF along with working sample code that you have used on your end to reproduce the issue.

hi @mudassir.fayyaz
I used this:

 public class Test {
public ByteBucketOutputStream stampTiff(InputStream is) throws IOException {

    try (ByteBucketOutputStream bucketOutputStream = new ByteBucketOutputStream();
         TiffImage image = (TiffImage) TiffImage.load(is)) {
        Rectangle rectangle = new Rectangle();
        rectangle.setTop(10);
        for (TiffFrame frame : image.getFrames()) {
            new Graphics(frame).drawImage(image, rectangle, GraphicsUnit.Pixel);
        }

        image.save(bucketOutputStream);

        return bucketOutputStream;
    } finally {
        // prevent memory leaks
        if (is != null) {
            is.close();
        }
    }
}
}

And as a result I want to get stamped multipage TIFF (not PDF as you mentioned above) which will have bigger size than original one.

I can provide you only with examples of tiff files I have:

  • source multipage tiff file;
  • multipage tiff which was stamped with text;
  • multipage tiff which was stamped with image.
    multipage_tiff_examples.zip (1.7 MB)

@paultomsky

I have created a ticket with ID IMAGINGNET-4416 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 addressed.

@paultomsky

Unfortunately the provided code is not complete (there is no stamp image) and we could not completely reproduce. However, related to source tiff image saving, we have found that you need to use different expected format that influence on image size.

We have tried to use :

image.Save(@"multipage_tiff_example_original_result.tif",new TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffDeflateRgb));

and

image.Save(@"multipage_tiff_example_original_result.tif",new TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffLzwRgb));

and for us, all worked as expected - ie image size increased after saving.

1 Like

hi @mudassir.fayyaz ,
thank you for your hints and examples, that’s exactly what I needed :slight_smile:
now resulting multipage tiff file have bigger size than original one.

@paultomsky

It’s good to know that suggested option has worked on your end.