Circle thumbnails

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
monsters

Post by monsters » 2006-12-11T10:56:55-07:00

Hi,

Images are of course rectangular by nature. What you could do is cut a rectangle out of the center of the image, and then place a white mask, or transparent mask in the shape you desire ( a circle) over top of it.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-13T22:46:47-07:00

You may not realise it by what you do on the commandline can also be generally done in PHP or other API.

Look at IM Examples Alpha Compositing for a solution.
Specifically 'Dst_Out' as an erase method.
http://www.cit.gu.edu.au/~anthony/graph ... se/#dstout
This is basic alpha composition and usable by all API's.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-14T16:53:59-07:00

OH! you want to overlay a white circle over an image, not turn an image into a circle!

Ok change the 'Dst_Out' to 'Screen' then position the source image (white circle) using
a geometry setting with the compose.

As you are drawing the circle, you can also just draw the circle directly on your fire image!
the center of the circle will be somewhere off the image, but that should be no problem.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-17T19:25:36-07:00

Your -geometry is a resize, I assume you aleady have the circle the right size, so you want to position it, not resize it.
EG -geometry +73+84
to position the circle.

however just draw directly on your image would be a LOT easier!

Code: Select all

   convert  image.png   -fill white -draw 'circle 36,40,65,45'  image.png
You need to just work out the location of the center and a point on the edge of the circle.
Note the center can be 'off' the image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-18T17:48:36-07:00

Okay. I may have misinterpreted your request.

What is wrong with...
Image

It does as you are describing. But you said it is "not working".
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-19T18:25:37-07:00

Two posible reasons...
1/ the original image does not have any alpha channel... add one using -matte
2/ you are saving to a format that does not use an alpha channel, EG: jpeg!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-25T18:27:11-07:00

what version of IM are you using?

Can you give us the commands with all the variables filled in? It is very hard to diagnose without all the details, and having to fill in the varables.
You can get a copy of the commands by adding a 'set -v;' to the start of each system call
so the command exectuted is 'verbosely' output to the caller.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony » 2006-12-29T23:00:03-07:00

Some basic rules to start with...

First I would not use GIF as an intermediate format. A final format yes ,but not a working format. Use PNG or MIFF, instead.

Second after the -crop, do a +repage to remove any old 'virtutal canvas' that may linger.

Thrird read in images BEFORE applying resize or crop or any other image effecting operation on them.

And finally is your white_mask.png a white (or some other color) circle on a transparent background? You don't have the code generating it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Circle thumbnails

Post by anthony » 2008-08-17T20:45:58-07:00

The problem is all the users articals were for some reason deleted. presumably by the user himself.

This is a real pain for others.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Circle thumbnails

Post by Bonzo » 2008-08-18T14:40:17-07:00

There are some php examples on my site - see my signature - including some circle example. Some of them could probably do with a tidy up.
Confirm what you want to do. This example of Anthony's can be written like this using php and the comand line:

Code: Select all

 exec("convert image.png -fill white -draw 'circle 36,40,65,45'  image.png");

Post Reply