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: 15
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Watermark Images in java using ImageMagick

Post by aamir4774@gmail.com »

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: 25562
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 »

Can't you just pipe the results in PNG format by using the output as PNG:- | ...
aamir4774@gmail.com
Posts: 15
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Re: Watermark Images in java using ImageMagick

Post by aamir4774@gmail.com »

@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: 25562
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 »

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: 15
Joined: 2019-03-05T22:47:03-07:00
Authentication code: 1152

Re: Watermark Images in java using ImageMagick

Post by aamir4774@gmail.com »

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