Crop with negative offsets
Posted: 2016-12-14T09:50:55-07:00
Hi, I'm trying to create backend for https://fengyuanchen.github.io/cropper/ plugin.
I have an image and data with cropping options from this plugin that's like {x:-100,y:200,width:300,height:300} array.
x and y are relative to the top left corner of an image.
The obstacle is that cropping area isn't necessary fit in the image. For example, width or height of the cropping area might be greater than the image's width and height. x and y may be negative. All these cases suppose to extend the cropped image with white color.
Please help to write the correct command for this case.
I tried:
$ convert pic.jpg -crop '300x300-100+200' -extend '300x300' out.jpg
- but this does not work correctly: it gives an image that has white margin from the right side while it should be on the left.
I have an image and data with cropping options from this plugin that's like {x:-100,y:200,width:300,height:300} array.
x and y are relative to the top left corner of an image.
The obstacle is that cropping area isn't necessary fit in the image. For example, width or height of the cropping area might be greater than the image's width and height. x and y may be negative. All these cases suppose to extend the cropped image with white color.
Please help to write the correct command for this case.
I tried:
$ convert pic.jpg -crop '300x300-100+200' -extend '300x300' out.jpg
- but this does not work correctly: it gives an image that has white margin from the right side while it should be on the left.