4

I've been tearing my hair out trying to figure out how to get gimp to do a scale in the way I want. I think what I'm after is either a non-linear scale, or a trapezoid distort. I'm not sure I'm using the right terms (which makes it hard to google potential solutions), so to demonstrate I've knocked up a couple of images. If this is my source image:

Original Image

Then this is what I want (I produced this manually to demonstrate):

Desired Image

I've tried the resize tools, but that only allows for square resizing, rather than a distorted scale like I want. The shear tool doesn't do scaling. Cage transform bends the image so that doesn't work either. Perspective distort is close, but affects the x position of the vertical lines which I don't want:

Close, but no cigar

I've also tried some of the filters but again couldn't get any of them to produce the effect I'm after (the curve bend filter seems like it might work, but I can't get it to produce the correct result).

I'm a fair programmer so if it needs a custom filter writing I can probably manage it if somebody could provide some tips as to what I need to do (some kind of matrix transform perhaps?)

  • 2
    Are you trying to produce a grid, or do you want the transform on a random image? For the former, I think I have the scripts. For the latter, a carefully crafted displace map could do it. – xenoid Jul 31 '16 at 22:20
  • 1
    No, I'm trying to transform an image, just used a grid to demonstrate how I need it stretched – Lee Aug 1 '16 at 6:24
  • 2
    I don't think you can get it simply with a matrix, because that would require your transform to be an affine transform, which it is not. An affine transform keeps all straight lines straight, and yours doesn't (diagonals become curves or instance) – xenoid Aug 1 '16 at 12:34
3

Possible solution with a displace map:

  • Create a group, with two layers:
    • At the bottom a layer that expresses the max displacement wanted: a black to white gradient (gray 50% is "no change", white and black will move things in opposite directions)
    • Above, an "attenuator" layer that will slowly grade the black-to-white gradient to a plain 50% gray (we don't want any changes on the right)
    • This layer has a layer mask with a black-to-white gradient (so, on the left, the displacement mask is seen in full, while, on the right, it fades into a play gray 50%). In practice this isn't strictly linear, but this can be compensated by using Curves to change the layer mask gradient.

layers and Curves settings

Then call Filters>Map>Displace map, and give the group as a displace map for the Y coordinate.

The result:

source and result

  • Just tried it and it works exactly as you describe, and is exactly what I asked for :) Nice technique - will have to remember that for similar 'odd' distortions if I need them. Cheers – Lee Aug 1 '16 at 21:17
-2

Although it does not fit your needs for this case, the "Perspective Transform tool" is what is used to achieve results like this - in order to simuate a 3d-space tilt of a 2D drawing.

As you had noted this far, there is no simple transform that can acheive what you want - I hope the displace hack provided in the other answer can it you, but otherwise, you'd rather try scripting the transform you want.

I yu want just a grid, a script to draw the ines directly. Otherwise, a script to perform a 1 pixel wide scale transform for each column in your image is the thing you should do.

  • 2
    The OP mentioned it doesn't work for him/her, because there should be no change along the X axis. – xenoid Aug 1 '16 at 12:29
  • There is no such transform. I understand it does nto work for thsi question in particular, but it is the thing to do for anyone else looking at the desired result. – jsbueno Aug 1 '16 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.