How to extend an image with stretched edges?
Posted: 2012-11-02T07:31:49-07:00
I'm working on a tool that can do several operations on an image.
Earlier I was able (with the help of this forum) to create an operation that adds mirrored edges to an image.
In that topic viewtopic.php?f=1&t=22071 I also asked some questions on creating stretched edges on an image.
For the stretched edges I want to have one single convert call that does all the transformations.
I've tried the virtual-pixel 'Edge' option but that is not exactly what I want. I want a range of edge pixels to be stretched, not 1 as is done in the virtual-pixel Edge option.
I've searched for some kind of "resize-part-of-image" option, but I could find it. So I decided that I would crop and resize each edge after each other and then append the different pieces.
I got it working when I do the operations in two convert calls, with the second call using the result image of the first call.
First call crops the part of the image that will be used for the rest of the operations (mpr:big -> center including the edges which will be stretched in the resize operations).
After that the center without the edges is cropped (mpr:center)
Then I crop the left edge (mpr:left) and stretch it (mpr:left_stretched). Then the right edge is cropped (mpr:right) and stretched (mpr:right_stretched).
Then I append the parts together and save it to a file lcr.jpg
Second call is using the created lcr.jpg image for the rest of the operations.
Again the center is cropped (mpr:center_tb -> center without the parts that is used for stretching the top and bottom edges). Then the top is cropped (mpr:top) and stretched (mpr:top_stretched) and also the bottom is cropped (mpr:bottom) and stretched (mpr:bottom_stretched).
Then the final image (stretched.jpg) is created by appending the top, center and bottom.
Problem is that when I want to do this in one call and use -write mpr:lcr instead of saving the first call to lcr.jpg, then the cropping of the top and bottom edges is wrong and the stretched edges are not as excpected (and is the two seperate calls).
It feels like if all the mpr 'in between images' is messing up the normal flow of operations.
Could anyone help me with this please, so that everything can be done in one call? Thanks!
Earlier I was able (with the help of this forum) to create an operation that adds mirrored edges to an image.
In that topic viewtopic.php?f=1&t=22071 I also asked some questions on creating stretched edges on an image.
For the stretched edges I want to have one single convert call that does all the transformations.
I've tried the virtual-pixel 'Edge' option but that is not exactly what I want. I want a range of edge pixels to be stretched, not 1 as is done in the virtual-pixel Edge option.
I've searched for some kind of "resize-part-of-image" option, but I could find it. So I decided that I would crop and resize each edge after each other and then append the different pieces.
I got it working when I do the operations in two convert calls, with the second call using the result image of the first call.
First call crops the part of the image that will be used for the rest of the operations (mpr:big -> center including the edges which will be stretched in the resize operations).
After that the center without the edges is cropped (mpr:center)
Then I crop the left edge (mpr:left) and stretch it (mpr:left_stretched). Then the right edge is cropped (mpr:right) and stretched (mpr:right_stretched).
Then I append the parts together and save it to a file lcr.jpg
Code: Select all
convert original.jpg -crop 2048x1411+0+127 -write mpr:big +delete +repage -crop 1932x1411+58+0 mpr:big -write mpr:center_lr +delete +repage -crop 58x1411+0+0 mpr:big -write mpr:left +delete +repage mpr:left -resize 117x1411! -write mpr:left_stretched +delete +repage -crop 58x1411+1990+0 mpr:big -write mpr:right +delete +repage mpr:right -resize 117x1411! -write mpr:right_stretched +delete +repage -gravity Center +append mpr:left_stretched mpr:center_lr mpr:right_stretched lcr.jpg
Again the center is cropped (mpr:center_tb -> center without the parts that is used for stretching the top and bottom edges). Then the top is cropped (mpr:top) and stretched (mpr:top_stretched) and also the bottom is cropped (mpr:bottom) and stretched (mpr:bottom_stretched).
Then the final image (stretched.jpg) is created by appending the top, center and bottom.
Code: Select all
convert -crop 2166x1295+0+58 lcr.jpg -write mpr:center_tb +delete +repage -crop 2166x58+0+0 lcr.jpg -write mpr:top +delete +repage mpr:top -resize 2166x117! -write mpr:top_stretched +delete +repage -crop 2166x58+0+1353 lcr.jpg -write mpr:bottom +delete +repage mpr:bottom -resize 2166x117! -write mpr:bottom_stretched +delete +repage -append mpr:top_stretched mpr:center_tb mpr:bottom_stretched +repage stretched.jpg
Code: Select all
convert original.jpg -crop 2048x1411+0+127 -write mpr:big +delete +repage -crop 1932x1411+58+0 mpr:big -write mpr:center_lr +delete +repage -crop 58x1411+0+0 mpr:big -write mpr:left +delete +repage mpr:left -resize 117x1411! -write mpr:left_stretched +delete +repage -crop 58x1411+1990+0 mpr:big -write mpr:right +delete +repage mpr:right -resize 117x1411! -write mpr:right_stretched +delete +repage -gravity Center +append mpr:left_stretched mpr:center_lr mpr:right_stretched -write mpr:lcr +delete +repage -crop 2166x1295+0+58 mpr:lcr -write mpr:center_tb +delete +repage -crop 2166x58+0+0 mpr:lcr -write mpr:top +delete +repage mpr:top -resize 2166x117! -write mpr:top_stretched +delete +repage -crop 2166x58+0+1353 mpr:lcr -write mpr:bottom +delete +repage mpr:bottom -resize 2166x117! -write mpr:bottom_stretched +delete +repage -append mpr:top_stretched mpr:center_tb mpr:bottom_stretched +repage stretched.jpg
Could anyone help me with this please, so that everything can be done in one call? Thanks!