← All text tools

Image to CSS gradient

Sample the colours of a picture along a line you draw and build a CSS linear gradient with 3 to 6 stops that matches its mood.

  • Free
  • No sign-up
  • Works on any device

About Image to CSS gradient

Take the mood of a photo and turn it into a background for your site. The tool follows a straight line across the picture, takes the average colour in a small window at evenly spaced points, and writes a CSS linear-gradient with three to six stops. The line starts as a horizontal sweep through the middle, and you can drag it or type its ends. The angle is worked out from the line, and a live bar previews the result.

How to use Image to CSS gradient

  1. Choose a picture and drag a line across the part you like.
  2. Pick the number of stops and how much to average around each point.
  3. Copy the CSS and paste it into your stylesheet.

Why use this tool?

Also known as

Frequently asked questions

How is the gradient angle chosen?

From your line. Left to right gives 90 degrees, top to bottom gives 180, and a diagonal line gives the matching diagonal angle.

Why average several pixels?

A single pixel can be noise or a speck. Averaging a 5 by 5 or larger window gives a calmer colour that matches the area.

How many stops should I use?

Three stops capture most scenes. Add more for a sunset or a multicolour image, but too many makes the gradient look busy.

Is Image to CSS gradient free?

Yes. Image to CSS gradient on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

Related tools