Search code examples
resolutiongimp

loss of resolution when using gimp transformation tools


I am using gimp 2.10.
When i use any transformation (rotate, resize,...etc) tool on part of an image,
it gets pix-elated even if i am resizing down and it gets worse with more transformations.
You can see the difference in this image image

How can i maintain resolution when using transform tools?


Solution

  • No, you can't, because transform tools (except Move and Flip) interpolate pixels. This is rather visible on hard edges (but check that you are using the NoHalo method).

    • Do all the transforms in one single call (all the transforms are affine transform (ie, a matrix).
      • You can use gimp_item_transform2D() to do a combined scale+rotate
      • If you do successive rotations or scalings, compute the resulting effect and apply it to the initial item. i.e., rotate by 10°, 20° , 30°... the initial object instead of rotating the result of the previous rotation by 10°.
      • In the bad cases, find the 3x3 matrix of the successive affine transforms, compute their product, and use that final 3x3 matrix in a call to gimp-item-transform-matrix() Do not iterate transforms
    • If you can transform the object into a path (text, for instance), apply the transforms to the path (you can even cumulate them), and once done recreate the object from the transformed path (usually, path to selection, and bucket-fill the selection)

    Also, when downscaling your picture can be subject to aliasing. The usual (and non-intuitive) cure is to pre-blur the picture before downscaling (if downscaling by N, apply a Gaussian blur of N pixels: 2px for a 50% reduction).