Free Support Forum - aspose.com

JPEG/JPG has less size after it’s stamped

Hello,

I hit the situation that my JPEG/JPG file’s size becomes less when I put a stamp (text or image) on it using aspose-imaging.
Is it possible to do something to avoid size decreasing while stamping JPEG/JPG?

Additional information: I had same question about multipage TIFF file previously: Multipage TIFF has less size after it's stamped
But I’m not sure how I should use JpegOptions in this case, maybe do you have any examples.
Thank you in advance.

@paultomsky

Please provide the source file, generated file and used sample code along with desired output. We will investigate that on our end to help you further.

hi @mudassir.fayyaz,
in zip you may find source file and result image with text stamp.
JPEG_examples.zip (24.6 KB)
Also, here’s a sample of code I use to stamp:

 class Test {
        public ByteBucketOutputStream stampImage(InputStream is) throws IOException {
            try (ByteBucketOutputStream bucketOutputStream = new ByteBucketOutputStream();
                 Image image = Image.load(is)) {
                RectangleF rectangle = new RectangleF();
                rectangle.setTop(10);
                Font font = new Font("Courier New", 14,0, GraphicsUnit.Pixel);
                SolidBrush brush = new SolidBrush();
                brush.setColor(Color.getBlack());
                new Graphics(image).drawString("text text",font,brush, rectangle);
                image.save(bucketOutputStream);
                return bucketOutputStream;
            } finally {
                // prevent memory leaks
                if (is != null) {
                    is.close();
                }
            }
        }
    }

@paultomsky

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