How to Keystone an image (pinch the bottom retain the top))
Posted: 2016-01-23T16:14:37-07:00
I've exhausted hours of playing with coordinates to try to get an image to keystone (distort perspective on bottom left and bottom right by an equal distance with no impact to the top anchor points). I'm doing this via command line. (as suggested in other threads, Wave Displacement didn't give decent results... perspective seems to retain the proportions best)
Image dimensions = 258Wx505H
I want to pinch both sides on the bottom by ~35px. Ideally, I want to pinch by a % of the original image, so I can pinch the bottom by 10% on each side - equally.
The code below works for a 258x505 image, however, I can't dynamically replicate this for images of various sizes.
My primary questions:
1 - how do I change the bottom left coordinate to 10% vs a fixed pixel coord of 35 (as seen above)? I tried to dozens of % configurations and they all throw errors. In order to change images of various sizes on the fly, I need a dynamic value, or model to define ~10%.
2 - bottom right coordinates of 160,50,160,65... for the life of me, nothing other than 65 works. I can change the other numbers, but nothing yields a simple pinch left effect by ~10%.
note: I've tried wave displacement to bulge the image, but it causes the image to become totally distorted. Distort perspective seems to give me the results that I need, but finding a simple coordinate model seems impossible. I can generate simple % based coordinates based on the original image size, but everything seems totally unpredictable.
Image dimensions = 258Wx505H
I want to pinch both sides on the bottom by ~35px. Ideally, I want to pinch by a % of the original image, so I can pinch the bottom by 10% on each side - equally.
The code below works for a 258x505 image, however, I can't dynamically replicate this for images of various sizes.
Code: Select all
convert magick.png -virtual-pixel transparent \
-distort Perspective '0,0,0,0 0,%h,35,%h %w,0,%w,0 160,50,160,65' \magick2.png
1 - how do I change the bottom left coordinate to 10% vs a fixed pixel coord of 35 (as seen above)? I tried to dozens of % configurations and they all throw errors. In order to change images of various sizes on the fly, I need a dynamic value, or model to define ~10%.
2 - bottom right coordinates of 160,50,160,65... for the life of me, nothing other than 65 works. I can change the other numbers, but nothing yields a simple pinch left effect by ~10%.
note: I've tried wave displacement to bulge the image, but it causes the image to become totally distorted. Distort perspective seems to give me the results that I need, but finding a simple coordinate model seems impossible. I can generate simple % based coordinates based on the original image size, but everything seems totally unpredictable.