GNOME Bugzilla – Bug 162877
rotation of misaligned images
Last modified: 2008-01-15 12:44:18 UTC
The attached patch adds a feature I am missing in Gimp since i saw it in Photoshop. I have a flatbed scanner and I often get images that are a bit rotated. To correct that I have to use the measure the angle of one of the picture's edges. Afterwards I have to use the rotate-tool to correct this angle. This patch helps filling in the right angle for the rotation: The last measured angle is stored and will be used to calculate a default angle for future rotations. Rotation can be done like this: use the measure-tool to draw/measure a line that should be exactly horizontal/vertical. Open the rotate-tool. Press 'Rotate', Finished! This is my first contribution to the OS community, so Im pretty shure this patch isnt perfect yet. (I just defined a new variable somewhere inside gimp.c to store the angle....)
Created attachment 35411 [details] [review] patch for gimp2.2.0
Why don't you just use the Corrective transform feature of the Rotate tool? Just align the grid with your misaligned image and have GIMP rotate it back. Closing the report as WONTFIX since your feature is already implemented, just better.
Hmm, I must admit that I dont like that method. For me it takes some effort to get the exact angle this way. These grid lines never are where I want them to be and its always like: 'are these two lines parallel? they look like...'
The problem with your solution is that it makes things easier for you but slightly harder for almost everybody else (who rarely do the same rotation over and over). If you can come up with a solution that does not have this problem, we might be more receptive. You might think, for example, of saving the rotation value in a way that allows it to be accessed by a script or plugin but does not use it to set the default; you could then write a simple "repeat-previous-rotation" script. Note also, for future reference, that your patch does not completely folow GIMP coding style. Thus, instead of tmp_angle=fmod((tmp_angle+45),90)-45; you should have tmp_angle = fmod ((tmp_angle + 45), 90) - 45; But this is less important than the usability issue.
I dont want to do the same rotation over and over. Therefore it really sounds a bit odd to use some value as default for all rotations. But 'my' default value is always between -45 and +45 degrees. At the moment a default of 0 is used. I understand that it could be a little bit confusing to have a none-zero default value, but I wont call that an issue: You never want to do a rotation by zero degrees, so you have to adjust the angle anyway. And 45 degrees is not too far away from zero... Maybe there could be a button inside the transfom menu to fill in that stored value, but that would be one click more for my method and I cant see the usability issue yet. What about a checkbox inside the preferences to toggle between my patch and a zero-default?
Using the measure tool in combination with the rotate tool is completely unintuitive. If at all, we would want to add this functionality in the rotate tool. Your patch is a bad hack and completely unacceptable, even after cleaning up the coding style issues. I also don't think we should make the results of the measure tool available to the PDB. It's purely a user interface thing and thus doesn't belong into the PDB.
Here is another thought: use the path tool instead of the measure tool, to create a simple straight-line path. You can then write a script that uses gimp-path-get-current to get the path you just created, gimp-path-get-points to extract the first two points, a little math to calculate the angle, then gimp-image-rotate to rotate by that angle, then gimp-path-delete to remove the path.
/me shudders. Why not simple add a mode to the rotate tool that allows to adjust a line and use that information to rotate the image? That's what this report is all about, no?
Because the bug was resolved as WONTFIX, and I wanted to suggest a solution that didn't require arguing about it. Reopening based on comment #8.
"Using the measure tool in combination with the rotate tool is completely unintuitive." Sven, please consider not referring to intuition as it's not evenly distributed across mankind. I've seen far too many users complaining about Measure tool not telling Rotate tool the measured angle. In fact, if you google for "straighten horizon" you'll see that combination of measure tool and rotate tool for straightening horizon is widely used. Backward mode of rotate tool a) is not really a discoverable solution and b) doesn't give enough precision, where as aforementioned combination does. Bill's suggestion to use path tool and calculate from its endpoint is logical (in fact hugin, panorama tool, uses a similar approach by calculating angle from two control points), but, sadly, same non-discoverable. A more obvious way could be a new tool based on Measure and Rotate tool that would do what Bill described: draw a line, automatically calculate from endpoints and rotate.
That could as well be part of the Rotate tool then. But seriously, there's not much need for a change here because we have the very powerful backward mode of the transform tools. It's somewhat redundant to talk about this further. If someone wants to see this improved, he/she should provide a patch.
We plan to include the Deskew plug-in at some point (http://www.cubewano.org/gimp-deskew-plugin/). This would probably make this request obsolete.
By the way, my usual way to use the rotate tool in corrective mode is to first drag one or several guides onto the image so that I have reference lines exactly where I want them, then rotate and align the features in the image with the guides. I do not see any advantages that the measure tool could have over that method, so I still suggest WONTFIX for this report (or OBSOLETE if Deskew is included).
Closing as WONTFIX since we seem to agree that the suggested approach is flawed.