使用PostCSS制作类似Instagram的图片

PostCSS

准备原始图像

这次我将使用这个图像,我想用PostCSS进行图像处理。

安装插件

      
npm install postcss-instagram
// or
yarn add postcss-instagram

// postcss.config.js
module.exports = (ctx) => ({
  plugins: [
    require('postcss-instagram')
  ]
});
      
    

1977

      
/* PostCSS */
.postcss__instagram { filter: 1977;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  filter: sepia(.5) hue-rotate(-35deg) saturate(1.6) contrast(.9);
}
.postcss__instagram:after {
  box-shadow: inset 0 0 3em #222;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Amaro

      
/* PostCSS */
.postcss__instagram { filter: amaro;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  hue-rotate(-10deg) contrast(.9) brightness(1.1) saturate(1.5)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 3em #222;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Brannan

      
/* PostCSS */
.postcss__instagram { filter: brannan;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  sepia(.5) contrast(1.3)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 3em #222;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Earlybird

      
/* PostCSS */
.postcss__instagram { filter: earlybird;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  sepia(.4) saturate(1.8) contrast(1.1) brightness(.9) hue-rotate(-20deg)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 3em #222;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Inkwell

      
/* PostCSS */
.postcss__instagram { filter: inkwell;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  grayscale(1) brightness(1.2) contrast(1.05)
}
      
    

Kalvin

      
/* PostCSS */
.postcss__instagram { filter: kalvin;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  sepia(.3) saturate(2.2) brightness(1.3) contrast(1)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 3em #555;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Lo-Fi

      
/* PostCSS */
.postcss__instagram { filter: lo-fi;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  contrast(1.5) brightness(.9) sepia(.05)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 7em #000;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Nashville

      
/* PostCSS */
.postcss__instagram { filter: nashville;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  sepia(.4) saturate(1.5) contrast(.9) brightness(1.1) hue-rotate(-15deg)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 100em #00f;
  opacity: .5;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}
      
    

Toaster

      
/* PostCSS */
.postcss__instagram { filter: toaster;}

/* build */
.postcss__instagram {
  position: relative;
  display: inline-block;
}
.postcss__instagram img {
  sepia(.4) saturate(2.5) hue-rotate(-30deg) contrast(.67)
}
.postcss__instagram:after {
  box-shadow: inset 0 0 3em #222;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  content: "";
}