In the manufacturing industry, spray painting is often an important part of the manufacturing process. Especially in the automotive industry, the perceived quality of the final product is closely linked to the exactness and smoothness of the painting process. For complex products or low batch size production, manual spray painting is often used. But in large scale production with a high degree of automation, the painting is usually performed by industrial robots. There is a need to improve and simplify the generation of robot trajectories used in industrial paint booths. A novel method for spray paint optimization is presented, which can be used to smooth out a generated initial trajectory and minimize paint thickness deviations from a target thickness. The smoothed out trajectory is found by solving, using an interior point solver, a continuous non-linear optimization problem. A two-dimensional reference function of the applied paint thickness is selected by fitting a spline function to experimental data. This applicator footprint profile is then projected to the geometry and used as a paint deposition model. After generating an initial trajectory, the position and duration of each trajectory segment are used as optimization variables. The primary goal of the optimization is to obtain a paint applicator trajectory, which would closely match a target paint thickness when executed. The algorithm has been shown to produce satisfactory results on both a simple 2-dimensional test example, and a non-trivial industrial case of painting a tractor fender. The resulting trajectory is also proven feasible to be executed by an industrial robot.