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.
Crop with negative offsets
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Crop with negative offsets
You might try using your geometry specifiers with the "-extent" operation and don't even use the "-crop". Something like this might do what you want...kasheftin wrote: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.
Code: Select all
convert pic.jpg -extent '300x300-100+200' out.jpg
Re: Crop with negative offsets
Thanks a lot, it works!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Crop with negative offsets
There is a cavat with using -extent, for image with transparency...
But as JPEG images have no transparency that should not be a problem for you.
See IM Exmaples
http://www.imagemagick.org/Usage/crop/#extent
But as JPEG images have no transparency that should not be a problem for you.
See IM Exmaples
http://www.imagemagick.org/Usage/crop/#extent
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/