Trim whitespace from top and bottom of image and distort
Posted: 2019-03-31T11:38:47-07:00
What I have - image with whitespace at top and bottom
What I want - image with no whitespace and content is distorted to fit space. This was done in photoshop
My method for achieving this is
1. Crop image into 1x256px slices
2. Trim the whitespace/transparent pixels from top and bottom
3. Resize the image to be 1x256 so the content is stretched
4. Montage
Seems to be working ok, but I have a bunch of odd artefacts at regular intervals through the image. Can't work out whether this is a problem with the montaging or the cropping!
Actual imagemagick image
What I want - image with no whitespace and content is distorted to fit space. This was done in photoshop
My method for achieving this is
1. Crop image into 1x256px slices
2. Trim the whitespace/transparent pixels from top and bottom
3. Resize the image to be 1x256 so the content is stretched
4. Montage
Code: Select all
convert original.png +repage -crop 1x -trim -resize 1x256\! out.png
montage out-*.png -geometry 1x -tile x1 montage.png
Actual imagemagick image