Hi,
For an experiment I need to use a big number of abstract shapes (white shapes on black background) all different from each other that are not correctly placed in the center of the picture. Since this is very important for the stimuli presentation, I wonder if there is a way for automatically, let's say, crop the shape and place it in the center (usign "gravity" or something) for example a function that detects the border of the shape or something like this. How would you solve this problem in ImageMagick?
Hope you can help me with this,
Thanks
Best
Ale
P.S. I don't know if relevant but I'm using a Mac
Center abstract shapes to the centre of the picture
Re: Center abstract shapes to the centre of the picture
Solution found:
convert mypic.png -trim mypic1.png
Done!
Ale
convert mypic.png -trim mypic1.png
Done!
Ale
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Center abstract shapes to the centre of the picture
WARNING. add a +repage after the -trim to remove the 'crop information' that is saved as a virtual canvas size and position.
If you need them all centered on a standard image size follow the +repage with a -gravity center -extent {WIDTH}x{HEIGHT}.
For example
If you need them all centered on a standard image size follow the +repage with a -gravity center -extent {WIDTH}x{HEIGHT}.
For example
Code: Select all
convert mypic.png -trim +repage -gravity center -extent 200x200 mypic1.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/