<p>Currently it’s not possible to hook into Craft’s own thumbnail/transform generation logic. Your best bet would be to write a plugin that independently adds the watermark.</p>

<p>You could give the plugin a <a href="http://buildwithcraft.com/docs/plugins/variables" rel="nofollow">Variable</a> class that accepts the AssetFileModel object, grabs the image, stamps it with the watermark and saves it somewhere else, returning the URL to that watermarked image, or something like that.</p>

CC BY-SA 3.0
2014-07-17T13:46:24.533Z
Interesting, however with this I won't be able to use any of the on-demand asset transforms? That's not a deal breaker in this case but wonder if Craft will ever support custom transforms.
Mark Huot
CC BY-SA 3.0
2014-07-17T14:09:59.770Z
Yeah it would need to be separate. We are planning on giving plugins a role in transforms, but can’t give you an ETA.
Brandon Kelly
CC BY-SA 3.0
2014-07-18T14:25:19.667Z
Thanks Brandon! No worries, the separate approach will work fine in this specific instance.
Mark Huot
CC BY-SA 3.0
2014-07-14T18:26:15.143Z
2014-07-14T18:26:15.143Z
Brandon Kelly
<p>I have a somewhat unique thumbnail need for a certain site. I need to watermark images with custom text (per image, not globally across the site). Is there a way to hook into the Craft image transform generation logic and insert/run my own logic?</p>

<p>I've experimented with <code>craft()-&gt;on('content.onSaveContent', function(Event $event) {</code> and it seems to work okay. It will run when you save/upload the asset. The downside is that it generates the thumbnail on save, instead of on demand (using Javascript) as the native Craft transform feature does.</p>

<p>So, is there a different event I can hook into? Or, is there a better way to adjust the transform generation logic.</p>

<plugin-development><assets><image-transforms><assetfilemodel>
Is it possible to hook into image transforms?
# Is it possible to hook into image transforms?

(Asked by: username_0 on 2014-07-13)

I have a somewhat unique thumbnail need for a certain site. I need to watermark images with custom text (per image, not globally across the site). Is there a way to hook into the Craft image transform generation logic and insert/run my own logic?

I've experimented with `craft()->on('content.onSaveContent', function(Event $event) {` and it seems to work okay. It will run when you save/upload the asset. The downside is that it generates the thumbnail on save, instead of on demand (using Javascript) as the native Craft transform feature does.

So, is there a different event I can hook into? Or, is there a better way to adjust the transform generation logic.

**Tags:** plugin-development, assets, image-transforms, assetfilemodel

---

## 1 answers

### Answer by username_1 on 2014-07-14. Score: 3 | Accepted answer

Currently it’s not possible to hook into Craft’s own thumbnail/transform generation logic. Your best bet would be to write a plugin that independently adds the watermark.

You could give the plugin a [Variable](http://buildwithcraft.com/docs/plugins/variables) class that accepts the AssetFileModel object, grabs the image, stamps it with the watermark and saves it somewhere else, returning the URL to that watermarked image, or something like that.

> **Comments:**
> **username_0**: Interesting, however with this I won't be able to use any of the on-demand asset transforms? That's not a deal breaker in this case but wonder if Craft will ever support custom transforms.  
> **username_1**: Yeah it would need to be separate. We are planning on giving plugins a role in transforms, but can’t give you an ETA.  
> **username_0**: Thanks Brandon! No worries, the separate approach will work fine in this specific instance.  

---

