Masking would be awesome - take png file with transparent background, draw any form with black fill and anti-aliased sides, upload in action and IC takes dynamic image and fills black area with that image. Complete freedom for designers - images in custom shapes with awesome border effects etc.

Comments

henrijs.seso’s picture

deleted comment

henrijs.seso’s picture

StatusFileSize
new221.25 KB

here is code example that does this: http://php.amnuts.com/index.php?do=hide&id=15

even working example http://php.amnuts.com/demos/image-mask/

good folk at stack overflow also has suggestions here http://stackoverflow.com/questions/2702769/image-gd-and-png-masking

could somebody make action out of this?

another illustration:

dman’s picture

I already have/had a working algorithm for full transparent mask from image.
It's is canvasactions.inc:canvasaction_mask()

Was used for rounded corners - until a more efficient version of the same job replaced it.

We can ressurect it, and probably expose it as a standalone action. Seemed like a useful tool ... but didn;t have much of an actual use for it.

henrijs.seso’s picture

i see code there, true. some way of mask upload is needed and separate action. i am making a web site with grungy look and want to use imagecache to create crazy masked images (they are not so crazy actually, all are pretty much standard thumbnails, just edge is cut not straight). there are 3 lead stories on main page and some thumbnails for galleries and stuff. I will make view (or theming) for each story to use different preset and therefore different mask. what would really kick ass is possibility to upload multiple masks (like 3-5, not more, otherwise all point of imagecache is lost) and then use them randomly, but thats probably too extreme and views method should be used :)

or maybe im thinking wrong and some kind of jquery solution is needed

henrijs.seso’s picture

i will use this meanwhile: http://www.netzgesta.de/edge/. this is ugly :(

dman’s picture

Actually, a randomizer option is not so silly.
We've currently got the aspect switcher, which delegates to other presets.
So you could define several styles, then create a master style with a 'random' switcher.

Note that here - as with other requests for 'dynamic' features, imagecache is a cache so 'random' only creates a new result the very first time. after that, the image has been saved in the cache and will remain.

henrijs.seso’s picture

I know, but i just didnt want to go to extremes, like photo gallery with 30 random thumbnails on same page. But seriously, yes, random could be an option, i am very familiar with aspect switcher functionality as well as 'dynamic' features. I would see how this could be useful.

RobW’s picture

I am looking for this functionality too, something where you specify a custom black and white image that an action uses to create a png alpha mask. Thanks for posting some current possible starting points; if someone created a standard Imagecache Action that accomplished this it would be very cool.

sydneyshan’s picture

StatusFileSize
new1.35 KB

I've been using a custom bit of code for the last 4-5 projects (see file attached). One day I'd like to give it a UI within Imagecache, but not sure when time will be available.... If anybody else would like to do so and submit it please do so!

dman’s picture

Looks like a fine idea.
I'd have thought that GD may have had a mask action built in instead of the per-pixel approach, but per-pixel is reliable - if not fast.

Thoughts on a UI for this? I imagine the scaling etc may cause issues in general production use. Would it be best to precede the mask action with a fixed-size scale first?

Screenshot example of your use-case? I don't have any ideas for this yet, but I can imagine someone does.

sydneyshan’s picture

StatusFileSize
new525.89 KB

Hi dman,

Yes you'd definitely want to scale/crop images before using the code.

I haven't got the spare time to invest in to this add-on at present, but if anybody else does please feel free to use my code as a base...

I've attached a snapshot of my usual workflow using the Custom Action code...

dman’s picture

Ah, Vignette!

Yes, that's a worthwhile use for full-alpha-masking.
... I just couldn't imagine what for OTTOMH, but this makes sense.
I'll stick it on the to-do list.

sydneyshan’s picture

Thanks, dman. Love your work.

puya’s picture

This is awesome.. is this going to be added as an action (preset) or do we hand code it in?

sydneyshan’s picture

Hi puya,

Thanks :) as far as I am aware this is still on dman's to-do list... Until then you'll need to use my custom code found in #9 comment...

-Shan

puya’s picture

Thanks a lot Shan, where do I put this code in? should I use the custom action preset?

sydneyshan’s picture

Hi puya,

Yep - just place the code into the Custom Action preset and adjust the path to the image mask manually.

puya’s picture

Thanks a lot Shan, Awesome I'm gonna try it. do I need the <?php tags?

sydneyshan’s picture

Hi puya, no <?php tags are required.

puya’s picture

Thanks a lot. Would this be committed to head sometime?

sydneyshan’s picture

Version: » 6.x-2.x-dev

dman, I haven't forgotten about this ... just looking in to getting git set up to contribute to this module.

sydneyshan’s picture

Assigned: Unassigned » sydneyshan
Status: Active » Needs review

Hi all, I've spent some time this week implementing this in to the Canvas Actions module for the 6.x-2.x-dev branch. It works well from what I can see, however the following 'TODO' items are left:

1. Change the Imagemagick operation(s) so that the target image's transparency is retained (currently it is lost) - this isn't an issue if you're feeding the action an image without transparency (which is usually the case)
2. implement offset support (this could open up the module to a whole range of uses)

Please try it out and let me know what your feedback is.

puya’s picture

thanks a lot.. will try it out for sure.

JacobSingh’s picture

I tried this, works. Pretty cool.

sydneyshan’s picture

Assigned: sydneyshan » dman
Status: Needs review » Reviewed & tested by the community

Great to hear! Dman, are you thinking we should commit this to a 6.x-2.1 branch?

dman’s picture

yeah i think so.
I've noy had enough time to tend to these things this month - big sites going live elsewhere - but yep, these new features can become a new release number!

nancydru’s picture

I'd love to have a vignette action (or documented technique) in both 6.x and 7.x.

fietserwin’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

The 6.x-2.x version has been discontinued. Please read this comment #1591826-1: 6.x-2.x-dev is no more supported . Please reopen this issue in another version (6.x-1,x-dev or 7.x-1.x-dev) if you still want the feature over there.

Glancing quickly over this issue I think that, at least in D7, the "Image mask" effect is what is asked here. Not sure if that effect is based on this code or not, and whether it is available in 6.x-1.x or not.