Apply watermark to full image?

74 views
Skip to first unread message

Alan Bailward

unread,
Sep 5, 2018, 5:34:46 PM9/5/18
to AtoM Users
I'm trying to get the watermark to apply to both the thumbnail image as well as the smaller version.  The images that are being uploaded are not the originals so I'm not worrying about damaging them, but it seems like only the medium sized images get the watermarks, and if you click on them you get the full size original image un-watermarked.  The person I'm setting the system up for wants the full size one watermarked as well.

I have no problem going in and editing code, but for the life of me I can't find where the image is actually stored to disk so I can run it through imagemagick the same as is done for the thumbnails.

Any help appreciated, assuming anyone actually monitors this group :)

Dan Gillean

unread,
Sep 5, 2018, 6:22:29 PM9/5/18
to ICA-AtoM Users
Hi Alan,

You will definitely need to make some code customizations to achieve what you want, but I can at least provide some links that might help you along.

First, basic documentation on how to set up the current watermarking functionality is here:
You're correct that it is only being applied to the reference display copy at the moment. You can see where this happens, and the ImgMagick command used, in this section of the code:
As for where digital objects are stored in AtoM - there is a directory called "uploads" just below the root AtoM installation directory. However, from there it gets more complicated to find things manually. I've previously provided a more detailed breakdown of how this directory is organized, and how you could potentially find the absolute path, in the following posts:
Finally, one other thing that may be of interest. A company called PeaceWorks once developed the ability to add watermarks on a per-institution basis, for the Mennonite Archival Image Database (MAID). They made the code open, but it was developed against an older branch and didn't follow our coding standard recommendations, and MAID had no budget at the time to sponsor any work required to get it into a public release. However, you can still access the code repository, and there's info on our wiki - it might be interesting or relevant for you to look at how they've modified the base code:
This is functionality that we would still love to see in a public release. It also allows upload of the watermark through the user interface, from what I understand. It might be possible for you to build on this.

If you have interest in sharing your work with the public AtoM project, I think we would want to see some settings added for this functionality, so a user could choose whether or not a watermark was applied to the master digital object (I assume that many wouldn't, so the default should be the less destructive option of no). We do have some resources on our wiki to help developers, here:
For details particularly on contributing code to the public project, see this page:

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To post to this group, send email to ica-ato...@googlegroups.com.
Visit this group at https://groups.google.com/group/ica-atom-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/baa27370-3ab0-461b-830a-b32b137e7444%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Bailward

unread,
Sep 5, 2018, 11:53:20 PM9/5/18
to AtoM Users
Great info there, thanks Dan!  If I'm reading the previous messages right, even if I merged in this commit:


That would just get me the option for a banner but still not give me access to watermark the main image.

I could just do a horrible ugly hack and run an hourly cron job that just runs through the originals directory, looks for any images, applies the watermark to them, creates a <filename>.watermarked file (so it doesn't re-watermark).

Super ugly, hacky, but it sounds like there's not an easy way to hook into the storing of the original image that's uploaded like you can with the thumbnail creation.

I've already modified the code to do the watermarking for the non-full size differently, is there any way you can point me to where in the code the original image is written to the disk?  If I can find this it would be pretty easy to run something at that point, but for the life of me I couldn't figure out where that was when I dug through :( 

Dan Gillean

unread,
Sep 7, 2018, 12:07:08 PM9/7/18
to ICA-AtoM Users
Hi Alan, 

You're correct, the PeaceWorks plugin won't solve your use case - I just thought it might be useful for you to see how others have manipulated related areas of the code, and share something you might choose to build on if it helps in other ways. 

Regarding where the uploads are written to disk, I think you will want to look at these files: 
I believe the first is for linking a single digital object, and the second is the form controller process that relates to uploading multiple digital objects as children of the target description. 

However, one warning about modifying these directly: 

Right now digital object linking and multi-object upload are both handled synchronously in real time, via the browser. This means that these processes are already susceptible to browser timeout limits that can abort the upload process and lead to errors, especially in cases where too large a DO is uploaded, or in the case of the mutli-upload, too many objects are added at once for the child information objects to be created and the uploads saved to disk before the browser's (generally default) 1 minute timeout limit is reached.

If you add further processing here, this will add further to the amount of steps to be completed, which could make the entire digital object module more susceptible to timeouts overall. 

As a long-term goal, we would love to begin handling digital object linking and upload asynchronously in the background, using the Job scheduler. However, this will require further development for us to be able to implement. As a community driven project maintained by a small company that makes  all of our primary resources freely available, we rely on community support (in the form of development sponsorship or community-submitted pull requests) to enhance AtoM. You can read more about our development philosophy and business model here.  

Rather than tackling an overhaul of the entire upload process, it may be possible to develop a smaller asynchronous job that iterates over uploaded digital objects and applies the watermark to the master after the upload is complete. In that case, you may want to look at previous commits and pull requests that add new jobs for reference. You can also see the existing Jobs in the code here

I hope that helps! 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory

Dan Gillean

unread,
Sep 7, 2018, 12:57:22 PM9/7/18
to ICA-AtoM Users
Hi again Alan, 

I've gotten a few more links and suggestions from our developers. One other way to approach this would be to handle the creation of a new copy of the master (with the watermark) applied when the derivatives are being created.

For the multi-uploader, here is where we call the save operation on the digital object. This save method can bee seen here - I've specifically highlighted the place where watermarking occurs (also shared in my first reply): 
Notice the usageId - at present, this process is only being run for the reference display copy derivative. However, adding a new section of code below here to act on the master digital object might be the best way to handle your use case. I believe that this should work for both methods of adding digital objects in AtoM, since both will call this save method. 

Hope this gives you some ideas to work with! 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory

Alan Bailward

unread,
Sep 15, 2018, 4:21:48 PM9/15/18
to AtoM Users
Ahh.... ok my mistake, I thought that chunk of code was *just* for the derivatives.  That explains a lot!  Should be all I need for this :)

Appreciate your help again Dan!
Reply all
Reply to author
Forward
0 new messages