Here is a different strategy. If you know, you are working with pages of text or line-content like in your second example, you can use this knowledge. A text is almost always arranged in long lines. Additionally, the contrast between the text and the background is often fairly high. That being said, Binarize should often work without parameters and give you a good separation between text (or lines) and background.
Lets try your two examples:
img1 = Import["https://i.stack.imgur.com/cCjyn.png"];
img2 = Import["https://i.stack.imgur.com/reBC0.png"];
Row[Binarize /@ {img1, img2}]

When you are using something like a gradient-orientation-filter, you end up with all the edges around single letters. Even if you, like in your example dilate the image first, the letters will make small bumps that all contribute to your list of orientations that you need to filter out.
When I understood your intention correctly, this is not what you want. How do you see that the image is slightly rotated? You see it because the lines of text are not quite horizontal.
A better approach would, therefore, be to work on objects that are a line of text. We know that letters in your example are really close together. So Closing will surely help to get rid of most of the gaps.
Let's see how far this brings us. The only parameter I'm using is the value for the morphological closing.
HighlightImage[
#,
Polygon /@
Values[ComponentMeasurements[Closing[Binarize[ColorNegate[#]], 3],
"MinimalBoundingBox"]]
] & /@ {img1, img2}

Some of the small objects don't represent the image orientation, but the larger objects are pretty good indicators for the rotation. Now, we can use the "Orientation"s of the objects with ComponentMeasurements but we have one final thing to deal with: There might be objects that are vertical. They too indicate the rotation, but we have to use their orientation with an offset of 90 Degree.
Let us write a small function f, that maps an input orientation to the correct orientation we want to use for rotating.
f[phi_] := With[{a = Mod[phi + Pi, Pi]},
Piecewise[{{a - Pi/2, Pi/4 < a < 3 Pi/4}, {a - Pi, 3 Pi/4 <= a}},
a]
]
and test it. Blue is the input orientation and red is what we will finally use to rotate the image.
Manipulate[
Graphics[{
Circle[],
Blue, Arrow[{{0, 0}, {Cos[phi], Sin[phi]}}],
Red, Arrow[{{0, 0}, {Cos[f[phi]], Sin[f[phi]]}}]
}], {phi, -Pi, Pi}
]

Putting all together gives us the following function
rotateBack[img_, closing_: 3, minLength_: 50] := Module[{
bin = Closing[Binarize[ColorNegate[img]], closing],
orientations
},
orientations =
Values[ComponentMeasurements[bin, "Orientation", #Length > minLength &]];
ImageRotate[img, -Median[f /@ orientations], Background -> White]
]
To get an idea how good this small function works, let us write a short highlighting code that puts some horizontal lines in the results:
Module[{nx, ny},
{nx, ny} = ImageDimensions[#];
HighlightImage[
#,
Table[Line[{{1, y}, {nx, y}}], {y, 1, ny, 30}]
]
] & /@ {rotateBack[img1], rotateBack[img2]}
Et voila

ImageRotate[im_, RandomReal[{0,2Pi}]to a bunch of images of text? – Greg Hurst Jul 29 '17 at 01:52