Page 1 of 1
Any way to crop an image using multiple coordinates?
Posted: 2014-03-17T04:05:51-07:00
by tirengarfio
Hi,
any way to crop an image using multiple coordinates?
For example:
Code: Select all
14, 45
30, 67,
35, 109
34, 1150
90, 1400
..
Re: Any way to crop an image using multiple coordinates?
Posted: 2014-03-17T04:37:21-07:00
by snibgo
I don't understand what you want. Images are always rectangular.
Re: Any way to crop an image using multiple coordinates?
Posted: 2014-03-17T05:18:10-07:00
by tirengarfio
Im working with this script:
http://iakob.com/canvas-area-draw/demo.html
https://github.com/fahrenheit-marketing ... -area-draw
as you can imagine, I would like to use those coordinates to crop the image in the server.
Re: Any way to crop an image using multiple coordinates?
Posted: 2014-03-17T05:27:28-07:00
by snibgo
What do you mean "I would like to use those coordinates to crop the image"?
Your script could find the maximum and minimum x-coordinates, and maximum and minimum y-coordinates, and crop to those.
Or it might turn everything inside the polygon black. Or everything outside white. Or everything outside transparent.
Re: Any way to crop an image using multiple coordinates?
Posted: 2014-03-17T06:23:13-07:00
by tirengarfio
snibgo wrote:What do you mean "I would like to use those coordinates to crop the image"?
As you can see on the demo, with that script you can draw an area which coordinates are inserted in an input field. After submitting the form, I would use those coordinates to crop the image, since I'm interested in showing
only that area in my website frontend.
snibgo wrote:Your script could find the maximum and minimum x-coordinates, and maximum and minimum y-coordinates, and crop to those.
but in that case the area will be a square, showing parts of the image that I'm not interested in. I just want the area I selected freely.
snibgo wrote:Or everything outside white.
In this case, could I drop using Imagemagick the area different from the white color? has Imageimagick any function to do this?
Re: Any way to crop an image using multiple coordinates?
Posted: 2014-03-17T06:53:19-07:00
by snibgo
I still don't understand what you want, but this might be it. Windows BAT syntax. Adjust for other languages.
Code: Select all
convert ^
in.png ^
( +clone -fill Black -colorize 100 ^
-fill White ^
-draw "polygon 208,221 208,202 198,199 201,191 218,176 229,155" ^
) ^
-alpha off ^
-compose CopyOpacity -composite ^
-trim +repage ^
out.png