Exif tags JPG not support. Need rotate pixel data

I encountered such a problem when loading textures for a material. Sketchup does not support EXIF Tags in jpg files. And images rotated by 90 degrees are displayed incorrectly.
What I think needs to be done:
•. Read parameter EXIF:Orientation.
•. Existing values

1 = Horizontal (normal)
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW

In my case, if the value is greater than 4
Load image to Sketchup::ImageRep and rotate pixel data in it, as DanRathbun has repeatedly said on the forum.

The first point is solved by gem EXIFR.
I have a problem with the second point. I don’t have enough knowledge to do pixel data conversion.
It is also not clear how to change the length and width. Help me with the second point, please.