Composite + -watermark messing up PNG overlay

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
Ryan Nutt

Composite + -watermark messing up PNG overlay

Post by Ryan Nutt »

I'm using the composite command to overlay a watermark onto images during upload on a script of mine. But if I include the -watermark x% flag in the command line it makes the image look like the one that's attached. If watermark is left out then the overlay works fine.

Image

Is there a setting I'm missing? Or does IM have problems with transparent PNGs and watermarking? This is the first time I've had anyone comment on this not working correctly, and I know it's worked before so it may be something with the watermark file but I'd still like to know what I can do to fix it.
Ryan Nutt

Re: Composite + -watermark messing up PNG overlay

Post by Ryan Nutt »

I now have two users reporting this problem. One has version 6.2.4, as do I on one of my development server and both are showing this problem. I don't know yet what version the other problem server is running.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Composite + -watermark messing up PNG overlay

Post by anthony »

the -watermark option, was actually never much good at watermarking!

See IM Examples, Annotating Images, Watermarking for a number of methods..
http://www.imagemagick.org/Usage/annota ... mark_image
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Ryan Nutt

Re: Composite + -watermark messing up PNG overlay

Post by Ryan Nutt »

Thanks Anthony, but using the dissolve is actually worse.

What I've done is added the option to use a GIF file as the watermark and it seems to work pretty well.

What doesn't make sense to me is that it's only certain PNG files that are causing problems, so I think it's more dependent on the file rather than IM. What I may wind up doing is using GD for the watermark command because it doesn't seem to have the same problem with the files my users have sent me but use IM for everything else because it generally does a better job.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Composite + -watermark messing up PNG overlay

Post by anthony »

Dissolve is just an overlay, with additional transparency.


What command do you use with GD. I'll look at exactly what it does to implement its watermark feature.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Ryan Nutt

Re: Composite + -watermark messing up PNG overlay

Post by Ryan Nutt »

It's got to be something about the way the PNG is saved out of Photoshop.

Now GD is causing problems too not letting me change the opacity. imagecopymerge seems to be the function that does what I need, but with the same PNG that's causing problems with IM imagecopymerge is just overlaying a solid white box in the size of the watermark file.

imagecopy will work, but it won't change the opacity.

Does Photoshop have issues in how it saves PNG files? I suppose I need to go and research why the PNG might have gotten screwed up out of Photoshop. My client sent me the source PSD and it looks fine in Photoshop, but opened in Irfanview the PSD just shows a white box as does the PNG that I saved from Photoshop.
Post Reply