CSSで写真を鉛筆画、色鉛筆画、水彩画風にエフェクト

2019-02-15 · 写真・カメラ アート・美術 ホームページ、Web作成

写真を鉛筆画、色鉛筆画、水彩画風にエフェクトをかけるCSSが見つかったので、試してみた。そのCSSは以下。

http://bennettfeely.com/image-effects/

下の「coliss」の紹介記事で知った。

驚きのクオリティで画像にエフェクトが適用できる、CSSのブレンドモードを使った実装テクニックのまとめ下記の4枚は、元の写真画像にCSSのブレンドモードや画像フィルタを適用したキャプチャです。 鉛筆画、色鉛筆画、水彩画、黒板(画?)など、かな…コリス

【オリジナル写真】

f:id:art2nd:20190215134408j:plain

【鉛筆画】

f:id:art2nd:20190215134418j:plain

<div class="pencil-effect">
	<img src="img/xxx.jpg">
</div>

<style>
.pencil-effect {
	background-image: url(img/xxx.jpg);
	background-size: cover;
	background-position: center;
	width: 600px;	/* jpgに合わせる。 */
	max-width: 100%; /* スマホ用 */
}
@supports (filter: invert(1)) and (background-blend-mode: difference) {
	.pencil-effect {
		background-image: url(img/xxx.jpg), url(img/xxx.jpg);
		background-blend-mode: difference;
		background-position: calc(50% - 1px) calc(50% - 1px), calc(50% + 1px) calc(50% + 1px);
		filter: brightness(2) invert(1) grayscale(1);
		box-shadow: inset 0 0 0 1px black;
	}
}
[class$=-effect] img {
	vertical-align: top !important;
	margin: 0 !important;
	opacity: 0 !important;
}
</style>

【色鉛筆画】

f:id:art2nd:20190215134430j:plain

<div class="colored-pencil-effect">
	<img src="img/xxx.jpg">
</div>

<style>
.colored-pencil-effect {
	background-image: url(img/xxx.jpg);
	background-size: cover;
	background-position: center;
	width: 600px;	/* jpgに合わせる。 */
	max-width: 100%; /* スマホ用 */
}
@supports (filter: invert(1)) and (mix-blend-mode: color) {
	.colored-pencil-effect {
		position: relative;
	}
	.colored-pencil-effect:before, .colored-pencil-effect:after {
		display: block;
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-size: cover;
		box-shadow: inset 0 0 0 1px black;
	}
	.colored-pencil-effect:before {
		background-image: url(img/xxx.jpg), url(img/xxx.jpg);
		background-blend-mode: difference;
		background-position: calc(50% - 1px) calc(50% - 1px), calc(50% + 1px) calc(50% + 1px);
		filter: brightness(2) invert(1) grayscale(1);
	}
	.colored-pencil-effect:after {
		background: inherit;
		mix-blend-mode: color;
	}
}
</style>

【水彩画】

f:id:art2nd:20190215134443j:plain

<div class="watercolor-effect">
	<img src="img/xxx.jpg">
</div>

<style>
.watercolor-effect {
	background-image: url(img/xxx.jpg);
	background-size: cover;
	background-position: center;
	width: 600px;	/* jpgに合わせる。 */
	max-width: 100%; /* スマホ用 */
}
@supports (filter: blur(2px)) and (mix-blend-mode: multiply) {
	.watercolor-effect {
		position: relative;
		overflow: hidden;
	}
	.watercolor-effect:before, .watercolor-effect:after {
		display: block;
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-size: cover;
	}
	.watercolor-effect:before {
		background-image: url(img/xxx.jpg), url(img/xxx.jpg);
		background-blend-mode: difference;
		background-position: calc(50% - 1px) calc(50% - 1px), calc(50% + 1px) calc(50% + 1px);
		filter: brightness(2) invert(1) grayscale(1);
		box-shadow: inset 0 0 0 1px black;
	}
	.watercolor-effect:after {
		background-image: url(img/xxx.jpg);
		background-position: center;
		mix-blend-mode: multiply;
		filter: brightness(1.3) blur(2px) contrast(2);
	}
}
</style>

★ 実際に試したHTMLとCSSのサンプルは以下

https://ok2nd.sakura.ne.jp/css-filter/effect.html

写真を鉛筆画、ペン画、版画、水彩画、油彩画のような絵画調に変換(加工)する「FotoSketcher」。アート加工。★写真を鉛筆画、ペン画、版画、水彩画、油彩画のような絵画調に変換するWindowsアプリ「FotoSketcher」が凄い。一応、フリーソフト…晴歩雨描 ·

「FotoSketcher」の水彩画のパラメーターの値を変えて試してみた。写真を絵画調にする Windows アプリ「FotoSketcher」のパラメーター値を変えるとどうなるかを試してみた。「ペイント5(水彩画…晴歩雨描 ·

北浜散策で撮った写真を「FotoSketcher」で水彩画風に加工してみた。★↑ 今日、北浜散策で撮った写真を「 FotoSketcher 」で水彩画風に加工してみた。 すべて、FotoSketcherの「ペイント5(…晴歩雨描 ·

iPad+Apple Pencil+Tayasui Sketches Proで、写真を下絵にして、ロットリングペンと水彩で絵を描いてみた。レイヤー使用。先日、 iPad + Apple Pencil+Tayasui Sketches Proで、水彩画を試してみた。 今回、写真を下絵にして、T…晴歩雨描 ·

CSS「box-shadow」で、写真にビネット効果をつけてみた。先日、 Windows アプリ GIMP で写真に ビネット 効果を与える加工をやってみた。 ビネット 効果とは、写真の四隅周辺の光量を落と…晴歩雨描 ·

過去のフイルムカメラの写真を、FotoSketcher「カートーン1」で鮮やかでおしゃれな絵画調に加工する。アート加工。過去のフイルムカメラの写真を一部デジタル化してあるが、あまり画質が良いとは言えない。 これを、WindowsアプリFotoSketcherの…晴歩雨描 ·