Watermark Images in java using ImageMagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
aamir4774@gmail.com
Posts: 10
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Watermark Images in java using ImageMagick

Post by aamir4774@gmail.com » 2019-04-16T02:15:38-07:00

I'm trying to watermark images in java using "ImageMagic's" shell command, passing it java's process builder. This is successfully generating the watermarked image and the output image is getting stored in my repository from where I'm doing the further processing.

But I need to implement a workflow in which I take the images as input, watermark them and without storing the watermarked output, I need to stream the images as output on the webpage, so is there a way by which I can make the watermarked output displayable on webpage; basically by collecting the output response from imagemagick and doing the further processing using java (which I'm aware of), but the important thing is if it's possible to collect the watermarked output as response from ImageMagick without storing it.

Any help on this would be held in high regards.
Thanks

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermark Images in java using ImageMagick

Post by fmw42 » 2019-04-16T09:35:49-07:00

Can't you just pipe the results in PNG format by using the output as PNG:- | ...

aamir4774@gmail.com
Posts: 10
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Re: Watermark Images in java using ImageMagick

Post by aamir4774@gmail.com » 2019-04-16T09:50:41-07:00

@fmw42 if we pipe the output, is it something that we do not require to store the output file in the repository?
If so can you please explain this with an example

User avatar
fmw42
Posts: 25123
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Watermark Images in java using ImageMagick

Post by fmw42 » 2019-04-16T10:38:26-07:00

If you are using command line or API, I believe you can produce an image in say PNG format and pipe it to your other processing.

convert image1 image2 -geometry +X+Y -gravity Z -compose over -composite PNG:- | <your other processing using - as the input>

The PNG:- generates a PNG format image that is piped without saving to disk as stdout and received as stdin for your other processing.

aamir4774@gmail.com
Posts: 10
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Re: Watermark Images in java using ImageMagick

Post by aamir4774@gmail.com » 2019-04-22T22:36:01-07:00

Hi @fmw42,

Thanks for your kind help, will look more into the piping feature of ImageMagick and will check how can I integrate it with my requirement. Once again, thanks for the help like always :)

Post Reply