drawing the complex shapes in imagemagick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

drawing the complex shapes in imagemagick

Post by atf4_solace »

Hello Team,
We are using the Version: ImageMagick 6.9.3-8 Q16 x86_64 2018-06-20 and Platform is LINUX and API is PHP using exec() function.

We are working on drawing shapes in ImageMagick.

For drawing B shape we have used below command and shape is completely dynamic based on database settings

Code: Select all

-draw ' polyline 0,0 533.3,0 bezier 533.3,0 666.7,173.3 533.3,346.7 polyline 533.3,346.7 400,346.7 400,453.3 533.3,453.3 bezier 533.3,453.3 666.7,613.3 533.3,800 polyline 533.3,800 0,800 0,0 ' 
For example, we tried with the B shape as shown in the screenshot below

http://prntscr.com/n1gei0

But the shape is not closing properly and the black triangle is coming inside shape that means B is not drawing properly and does not have the backgeound image all over the shape
So, could you please suggest the solution to solve this problem as well please suggest to draw the shape with a curve in shapes

Thank You
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: drawing the complex shapes in imagemagick

Post by snibgo »

I'm not sure what you want.

The first polyline has only two points so merely draws a straight line.
The second polyline draws a rectangle.
The third polyline draws a large triangle.
If that's not what you want, then what do you want?
snibgo's IM pages: im.snibgo.com
atf4_solace
Posts: 18
Joined: 2017-09-15T07:57:03-07:00
Authentication code: 1151

Re: drawing the complex shapes in imagemagick

Post by atf4_solace »

Thanks for the reply Snibgo.

We just wanted to crop an Image in particular shape and shape is completely dynamic means we store the shape data in the database and we wanted to crop image based on that database data.

The shape is not just made from straight lines and it also includes curves in it.
For example, I wanted to crop the image in B shape so B shape is having two curves in it and others are straight lines.

So can we do such shape cropping on the image in one draw command and compose option and it will be based on database
Again some processing is done on that cropped B shape image and below is the screenshot of the cropped image.

the screenshot shows the B is not correctly cropped with our solution and that is the concern

http://prntscr.com/n1gei0

Thank You
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: drawing the complex shapes in imagemagick

Post by snibgo »

IM is drawing the shapes that you have asked for.

The shapes together don't look to me like a letter "B".

I suggest you take a sheet of graph paper. Draw the shape you want on it. Divide that shape into rectangles and curves. This will give you the coordinates of the corners of the rectangles etc.
snibgo's IM pages: im.snibgo.com
Post Reply