如何复制PS多层模式
有人知道使用图像或 CSS 复制 Photoshop 多层模式的好方法吗?
我正在开发一个项目,该项目的缩略图会在您将鼠标悬停在缩略图上时获得颜色叠加,但设计人员使用了一个图层集来进行乘法,而我不知道如何在网络上生成它。
我想出的最好的办法是使用 rgba 或透明 png,但即使如此,它看起来也不正确。
Does anybody know of a good way to replicate Photoshop's multiply layer mode using either an image or CSS?
I'm working on a project that has thumbnails that get a color overlay when you hover over them, but the designer used a layer set to multiply and I can't figure out how to produce it on the web.
The best thing I've come up with is either using rgba or a transparent png, but even then it doesn't look right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
为此引入了新的 CSS 属性,它们是
blend-mode
和background-blend-mode
。目前,您无法在任何类型的生产环境中使用它们,因为它们非常新,目前仅受 Chrome Canary(实验性网络浏览器)和 Chrome 浏览器的支持。 Webkit 每晚。
这些属性的设置与 Photoshop 的混合模式几乎完全相同,并且允许将各种不同的模式设置为这些属性的值,例如
overlay
、screen
、减亮
、颜色减淡
,当然还有乘法
..等等。blend-mode
将允许图像(可能还有内容?目前我还没有听到任何建议。)彼此分层以应用这种混合效果。background-blend-mode
非常相似,但用于背景图像(使用background
或background-image
设置)而不是实际的图像元素。编辑:
随着浏览器支持的不断增长,下一节变得有点无关紧要。检查此图表以查看哪些浏览器对此支持:http://caniuse.com/#feat=css-backgroundblendmode
如果您的计算机上安装了最新版本的 Chrome,您实际上可以通过启用浏览器(只需将它们放入您的地址栏即可:)
启用这些坏男孩,然后查看此小提琴:http://jsfiddle。网/cqzJ5/
(如果您的浏览器中正确启用了样式,则应将两个图像混合以使场景看起来像是在水下)
虽然这可能不是当前最合法的答案,因为几乎完全不支持此功能,我们希望现代浏览器在不久的将来能够采用这些属性,为我们提供一个非常好的且简单的解决方案来解决这个问题。
有关混合模式和 css 属性的一些额外阅读资源:
There are new CSS properties being introduced to do just this thing, they are
blend-mode
andbackground-blend-mode
.Currently, you won't be able to use them in any sort of production environment, as they are very very new, and currently only supported by Chrome Canary (experimental web browser) & Webkit Nightly.
These properties are set up to work nearly exactly the same as photoshop's blending modes, and allow for various different modes to be set as values for these properties such as
overlay
,screen
,lighten
,color-dodge
, and of coursemultiply
.. among others.blend-mode
would allow images (and possibly content? I haven't heard anything to suggest that at this point though.) layered on top of each other to have this blending effect applied.background-blend-mode
would be quite similar, but would be intended for background images (set usingbackground
orbackground-image
) rather than actual image elements.EDIT:
The next section is becoming a bit irrelevant as browser support is growing.. Check this chart to see which browsers have support for this: http://caniuse.com/#feat=css-backgroundblendmode
If you've got the latest version of Chrome installed on your computer, you can actually see these styles in use by enabling some flags in your browser (just throw these into your address bar:)
Enable those bad boys and then check out this fiddle: http://jsfiddle.net/cqzJ5/
(If the styles are properly enabled in your browser, the two images should be blended to make the scene look like it is underwater)
While this may not be the most legitimate answer at the current moment due to the almost entirely nonexistent support for this feature, we can hope that modern browsers will adopt these properties in the near future, giving us a really nice and easy solution to this problem.
Some extra reading resources on blending modes and the css properties:
简单,有一点 SVG:
和一些 CSS:
小提琴: http://jsfiddle.net/7uCQQ/381/
Simple with a bit of SVG:
and some CSS:
The fiddle: http://jsfiddle.net/7uCQQ/381/
郑重声明一下,这个人正在开发一个库来做到这一点。我是在做研究的时候才接触到的,还没有尝试过。
https://github.com/Phrogz/context-blender
Just for the record, this guy is developing a library to do so. I just came into it while doing a research, haven't tried yet.
https://github.com/Phrogz/context-blender
24.png 是可能的——如果你知道窍门的话。
在 illustrator 中,您可以将图形导出为 24.png,但这似乎永远不会像乘法那样工作。
我已经找到了。
就像 z 时的乘法一样-图片顶部的索引(ed)。
It is possible with a 24.png - if you know the trick.
In illustrator you can export the graphic as a 24.png, but this never seems to work like multiply.
I've found away.
works just like a multiply when z-index(ed) on top of a picture.
没有这样的能力。您获得的唯一接近的合成选项是:
上的
lighter
合成模式(是 a+b 而不是 a*b,并且与相乘具有相反的效果)min
或subtract
Compositor
仅在 IE 中过滤。两者都不是真正实用的。
一般来说,您不应尝试将 Photoshop 合成导出为图层,而应将它们渲染为单个不透明图像。对于翻转,您可以制作两个图像(一个用于正常状态,一个用于悬停)并使用 CSS
:hover
样式在它们之间交换以选择不同的背景图像,或者更好,因为它不需要预加载并减少 HTTP 请求 - 将两个图像合并为一个,并使用background-image
/background-position
在每种状态下显示该图像的右侧部分作为背景图像。 (“CSS 精灵”)No such ability is available. The only compositing options you get that are even close are:
lighter
compositing mode on an HTML5<canvas>
(which is a+b not a*b, and has about the opposite effect to multiply)min
orsubtract
Compositor
filters in IE only.Neither are really practical.
In general you should not attempt to export Photoshop comps as layers, but render them down to a single opaque image. For rollovers you can make two images (one for normal state, one for hovered) and swap between them using the CSS
:hover
style to choose a different background image, or—better, as it requires no preloading and reduces HTTP requests—combine both images into one and usebackground-image
/background-position
to display the right part of that image in each state as a background image. (“CSS sprites”)我最近需要完全按照OP的要求去做,所以我到处搜索。我发现了一种在 Photoshop 中制作透明 PNG 来复制乘法效果的好方法。
层。
Alt/Option + 单击
蒙版本身。Cmd/Ctrl + i
反转刚刚粘贴的图层。不透明度
。所有功劳都归于 Sojeong https://superuser.com/questions/381704/multiply-blending-模式转png
I recently had the need to do exactly what the OP asked so I searched around. I found a great way to replicate the multiply effect by making a transparent PNG in Photoshop.
layer.
Alt/Option + click
on the mask itself.Cmd/Ctrl + i
to invert the layer you just pasted.opacity
of the masked layer we created.All credit goes to Sojeong from https://superuser.com/questions/381704/multiply-blending-mode-to-png
看看这个:
http://www.webdesign.org/photoshop /photoshop-basics/remove-white-using-channels.10545.html
使用这些说明,我非常成功地为黑白图像添加了水印(在我的例子中是墨水画,在实体上有黑色和灰色)白色背景)到深色背景(在我的例子中是木材)。与Adobe真正的Multiply滤镜几乎没有任何区别。
我使用 Photoshop 说明从图像中删除白色,只在透明背景上留下黑色和灰色。将其保存为 PNG 并将其放在 CSS/HTML 中的木头上仍然看起来比相乘要糟糕得多,但是强烈降低 PNG 的亮度解决了这个问题(之前的浅灰色很突出,使其变得丑陋)。
一般来说,我建议你在 Photoshop 中尝试一下,复制网页情况:在纯色背景上有一个半透明(没有特殊的东西)层。诸如上述的教程可能允许您重现乘法或其他奇特的效果。
Check this out:
http://www.webdesign.org/photoshop/photoshop-basics/remove-white-using-channels.10545.html
Using those instructions, I had great success watermarking a black-and-white image (ink drawing in my case, with blacks and greys on a solid white background) onto a dark background (wood in my case). There is hardly any difference with the real Multiply filter of Adobe.
I used the Photoshop instructions to remove the whites from my image, leaving only blacks and greys on a transparent background. Saving this to PNG and putting it on the wood in CSS/HTML still lookedmuch worse thanmultiply, but strongly reducing the brightness of the PNG solved it (the light greys stood out before, making it ugly).
In general I recommend you play around in photoshop, replicating the web situation: a semi-transparent (no special stuff) layer on top of a solid background. Tutorials such as the above may allow you to reproduce multiply or other fancy effects.
不确定你是否会有运气。据我所知,即使你尝试将一些高级 JavaScript 与它集成也是不可能的。
Not sure if you will have any luck. As far as I know, it isn't possible even if you tried to integrate some advanced JavaScript with it.