如何复制PS多层模式

发布于 2024-09-03 12:29:16 字数 175 浏览 4 评论 0原文

有人知道使用图像或 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

薄暮涼年 2024-09-10 12:29:16

为此引入了新的 CSS 属性,它们是 blend-modebackground-blend-mode

目前,您无法在任何类型的生产环境中使用它们,因为它们非常新,目前仅受 Chrome Canary(实验性网络浏览器)和 Chrome 浏览器的支持。 Webkit 每晚。

这些属性的设置与 Photoshop 的混合模式几乎完全相同,并且允许将各种不同的模式设置为这些属性的值,例如 overlayscreen减亮颜色减淡,当然还有乘法..等等。

blend-mode 将允许图像(可能还有内容?目前我还没有听到任何建议。)彼此分层以应用这种混合效果。

background-blend-mode 非常相似,但用于背景图像(使用 backgroundbackground-image 设置)而不是实际的图像元素。


编辑:
随着浏览器支持的不断增长,下一节变得有点无关紧要。检查此图表以查看哪些浏览器对此支持:http://caniuse.com/#feat=css-backgroundblendmode


如果您的计算机上安装了最新版本的 Chrome,您实际上可以通过启用浏览器(只需将它们放入您的地址栏即可:)

chrome://flags/#enable-experimental-web-platform-features
chrome://flags/#enable-css-shaders

* note that the flags required for this might change at any time

启用这些坏男孩,然后查看此小提琴:http://jsfiddle。网/cqzJ5/
(如果您的浏览器中正确启用了样式,则应将两个图像混合以使场景看起来像是在水下)

虽然这可能不是当前最合法的答案,因为几乎完全不支持此功能,我们希望现代浏览器在不久的将来能够采用这些属性,为我们提供一个非常好的且简单的解决方案来解决这个问题。

有关混合模式和 css 属性的一些额外阅读资源:

There are new CSS properties being introduced to do just this thing, they are blend-mode and background-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 course multiply.. 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 using background or background-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:)

chrome://flags/#enable-experimental-web-platform-features
chrome://flags/#enable-css-shaders

* note that the flags required for this might change at any time

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:

娇女薄笑 2024-09-10 12:29:16

简单,有一点 SVG:

<svg width="200" height="200" viewBox="10 10 280 280">
    <filter id="multiply">
        <feBlend mode="multiply"/>
    </filter>
    <image id="kitten" x="0" y="0" width="300" height="300" xlink:href="http://placekitten.com/300" />
</svg>

和一些 CSS:

#kitten:hover {
    filter:url(#multiply);
}

小提琴: http://jsfiddle.net/7uCQQ/381/

Simple with a bit of SVG:

<svg width="200" height="200" viewBox="10 10 280 280">
    <filter id="multiply">
        <feBlend mode="multiply"/>
    </filter>
    <image id="kitten" x="0" y="0" width="300" height="300" xlink:href="http://placekitten.com/300" />
</svg>

and some CSS:

#kitten:hover {
    filter:url(#multiply);
}

The fiddle: http://jsfiddle.net/7uCQQ/381/

月光色 2024-09-10 12:29:16

郑重声明一下,这个人正在开发一个库来做到这一点。我是在做研究的时候才接触到的,还没有尝试过。

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

风情万种。 2024-09-10 12:29:16

24.png 是可能的——如果你知道窍门的话。

在 illustrator 中,您可以将图形导出为 24.png,但这似乎永远不会像乘法那样工作。

我已经找到了。

  1. 让您的相乘图形在其
  2. 后面放置一个纯黑色 100% 框,然后
  3. 在透明度窗口中选择两个图形,选择“制作蒙版”,然后选择“反转蒙版”
  4. 导出为 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.

  1. get your multiplied graphic on its own
  2. place a solid black 100% box behind it, and select both graphics
  3. in the transparency window select 'Make Mask' and then 'Invert Mask'
  4. export as a 24.png file

works just like a multiply when z-index(ed) on top of a picture.

゛清羽墨安 2024-09-10 12:29:16

没有这样的能力。您获得的唯一接近的合成选项是:

  • HTML5 上的

    lighter 合成模式(是 a+b 而不是 a*b,并且与相乘具有相反的效果)

  • minsubtract 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 or subtract 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 use background-image/background-position to display the right part of that image in each state as a background image. (“CSS sprites”)

风吹雨成花 2024-09-10 12:29:16

我最近需要完全按照OP的要求去做,所以我到处搜索。我发现了一种在 Photoshop 中制作透明 PNG 来复制乘法效果的好方法。

  1. 创建一个与乘法相同尺寸的新文档
    层。
  2. 将文档填充为黑色。
  3. 添加矢量蒙版(图层窗口底部“fx”图层左侧的图标)。
  4. Alt/Option + 单击 蒙版本身。
  5. 现在将您的多重图层复制并粘贴到蒙版中。
  6. Cmd/Ctrl + i 反转刚刚粘贴的图层。
  7. 在该图层下方创建一个新图层,并将图像添加到多重叠加后面。
  8. 一切看起来都应该非常接近您想要的结果。如果需要,您可以调整我们创建的蒙版层的不透明度
  9. 当它看起来不错时,只需切换底层的可见性并将遮罩层另存为 PNG 即可!

所有功劳都归于 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.

  1. Create a new document with the same dimensions of your multiply
    layer.
  2. Fill the document with black.
  3. Add a vector mask (the icon to the left of layer "fx" at the bottom of the layers window).
  4. Alt/Option + click on the mask itself.
  5. Now copy and paste your multiply layer into the mask.
  6. Cmd/Ctrl + i to invert the layer you just pasted.
  7. Create a new layer below this layer and add the image behind the multiply overlay.
  8. Everything should look pretty close to your desired result. If needed, you can adjust the opacity of the masked layer we created.
  9. When it looks good just toggle the bottom layer's visibility and save the masked layer as a PNG et voila!

All credit goes to Sojeong from https://superuser.com/questions/381704/multiply-blending-mode-to-png

以歌曲疗慰 2024-09-10 12:29:16

看看这个:
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.

沉溺在你眼里的海 2024-09-10 12:29:16

不确定你是否会有运气。据我所知,即使你尝试将一些高级 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文