Page 1 of 1

"clone"/extend right most column of pixels to fit available space

Posted: 2015-01-25T20:18:51-07:00
by SteveTheTechie
How to use PerlMagic to duplicate/extent the right most column of pixels from an image to fit a given width.

See the masthead image at the top of http://brian.toastmastersclubs.org, for example. I want to be able to dynamically vary the width of this image to adapt it to varying user screen widths by duplicating the right most column of pixels in the image to fill the empty space on the left and right sides of the image.

Re: "clone"/extend right most column of pixels to fit available space

Posted: 2015-01-26T07:20:33-07:00
by snibgo
There is probably a better way, but this works. Windows BAT syntax. Sorry, I don't know Perl.

Suppose you want the banner to become 1234 pixels wide.

Code: Select all

convert ^
  club1.jpg ^
  ( +clone ^
    -flop -crop 1x+0+0 +repage ^
    -scale 123400%%x100%% ^
  ) ^
  +swap ^
  -gravity West ^
  -composite ^
  out.png
This makes a copy, mirror-images it left-to-right, and takes the first column. So now we have just the last column of the original image, one pixel wide. We scale it 123400% horizontally and 100% vertically. This stretches it out to 1234 pixels wide. We swap these, and place the original over the stretched image, left-justifying it.

If you can, you should start from a source that isn't a jpeg.

Re: "clone"/extend right most column of pixels to fit available space

Posted: 2015-01-31T12:42:44-07:00
by SteveTheTechie
Thank you very much!!! I will give this a shot.