I was on Pinterest and saw this image. It is pretty new to me and I have no idea where to start? How would you achieve this in any program? Please help me.
It's all a bit easier to discuss if we start with horizontal lines, like so:
As Ilmari Karonen said, this is just a displacement map. You start with a 3D topography h(x,y), and then each point (x,y) in the result should use the line starting at y0 = y − h(x,y).
With raster graphics, this can be rendered straight away, but to get clean vector lines we'd actually need to work the other way around: each line should be parameterised as
fy0(x) = y0 + h(x, fy0(x))
The problem is that this is only an implicit defining equation, because the RHS contains y = fy0(x). This could be solved with Newton-Raphson, but there's a simpler way: just construct the lines going from left to right, and at each point go up or down as needed to fulfill the equation. Assuming continuity, this is always just a small update, so we can approximate h as constant there.
Implementation in Haskell:
type ℝ = Double horizContourLine :: ((ℝ,ℝ) -> ℝ) -- ^ The topography/height function -> (ℝ,ℝ) -- ^ x-interval on which to render the path -> ℝ -- ^ Step size / resolution along the path -> ℝ -- ^ Base-level y-coordinate of the line -> [(ℝ,ℝ)] -- ^ Trail line horizContourLine h (x₀,xe) δx y₀ = go (x₀,y₀) where go (x,y) = (x,yTgt) : if x<xe then go (x+δx, yTgt) else  where yTgt = y₀ + h (x,y)
Then, with a suitable image input like
we get contours like
Rotation to diagonal lines is left as an exercise.
This is basically just a displacement map applied to a bunch of lines.
The tricky part is that applying a displacement map to a bitmap texture will stretch and compress the entire texture, including both the lines and the gaps between them. To get the shading effect in your example image, you'll want to stretch only the gaps, not the lines themselves. I can see two (or maybe three) ways around this:
Use a vector image editor that can be configured to only displace the path of the lines while leaving their width unchanged. I'm not sure if any common off-the-shelf vector drawing software (Illustrator, Inkscape, etc.) supports this, but if they do, that would probably yield the cleanest result.
In a bitmap editor (Photoshop, GIMP, etc.), start with a texture consisting of alternating black and white stripes of equal width, apply the displacement map to that, then use an edge detection filter to convert the stripe boundaries into lines (or maybe auto-trace the displaced stripe boundaries in a vector drawing program). The risk here is that, unless you work at a very high resolution (and then scale the final result down), the quality may suffer due to aliasing.
Write your own software to do one of the above. Obviously this requires some programming skills that not everybody has, but as far as graphics programming tasks go, this actually shouldn't be a particularly hard one.
I actually tested option 2 using the displace filter in GIMP. Unfortunately I don't really have time to write a step-by-step walkthrough right now (maybe later…), but as a teaser, here's the final result of my quick experiment:
The "displacement" mentioned by Ilmari Karonen and "relief effect" mentioned by Abdul Qayum are almost the same thing.
Here are some pictures from Image Relief Algorithm and its Application in Security Printing. We use an image to make cells (or grids) irregular (or to have a displacement), and then draw parrallel lines on them.
You can implement this algorithm by hands or use a software, such as GIMP displacement map or JURA (used by Abdul Qayum).