How to get color information

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?".
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: How to get color information

Post by VanGog »

Anthony:
Can you explain me why this command:

Code: Select all

convert -size 250x250 xc:white -draw "point 20,15 point 150,25 point 200,140 point 15,125" -bordercolor black -border 7 -trim  -format "%P%O" -write info: output.gif
    264x264+7+7

Why the image (canvas) is 264x264 and not 250x250? This is confusing.

I would expect number like 250x250+25+15
250x250 is dimension of canvas. 25 because the first vertical line of cut is 25 pixels from the left edge of the canvas. 15 because the first horizontal line of cut is 15 pixels from the top edge of the canvas. So why this incorrect number: 264x264+7+7

This is example how it should look in PS:
Image

I know about that link, I watched it to create the dots. I need only single dots for this.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to get color information

Post by anthony »

VanGog wrote:Why the image (canvas) is 264x264 and not 250x250? This is confusing.

I would expect number like 250x250+25+15
250x250 is dimension of canvas. 25 because the first vertical line of cut is 25 pixels from the left edge of the canvas. 15 because the first horizontal line of cut is 15 pixels from the top edge of the canvas. So why this incorrect number: 264x264+7+7
You started with a 250x250 canvas, then added a 7 pixel border to all sizes making the canvas (and virtual canvas) 264x264 The trim only trimmed the actual added border, reducing it to a 250x250 real image on a 264x264 virtual canvas, with a +7+7 offset.

virtual information
%W page (canvas) width
%H page (canvas) height
%X page (canvas) x offset (including sign)
%Y page (canvas) y offset (including sign)
%O page (canvas) offset ( = %X%Y )
%P page (canvas) size ( = %Wx%H )
%g layer canvas page geometry ( = %Wx%H%X%Y )

real image info (at the offset on the virtual canvas)
%w current width in pixels
%h current image height in pixels
%G image size ( = %wx%h )

I myself like to list information as...
%G%O on %P
The first is the 'crop' that was used on a virtual canvas.

If you remove the -format to get the default 'format' output, you will see real image, then virtual image information listed. -format is typically used to just get exactly the information wanted and no more.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: How to get color information

Post by VanGog »

Oh. I wanted to trim the pixels, than add border, and then trim again.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: How to get color information

Post by VanGog »

I need help with this. I have txt output:

9,82: (255,255,255) #FFFFFF white

How to get just

9,82:white

?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to get color information

Post by fmw42 »

I don't know how you would do this in windows, but in unix, one way is:


str="9,82: (255,255,255) #FFFFFF white"
echo "$str" | sed -n 's/^\(.*,.*\):.*[#].* \(.*\)$/\1:\2/p'
9,82:white

See if windows has sed function
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: How to get color information

Post by VanGog »

I thought you use fx
http://www.imagemagick.org/script/fx.php
to filter the output of txt:-
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to get color information

Post by fmw42 »

VanGog wrote:I thought you use fx
http://www.imagemagick.org/script/fx.php
to filter the output of txt:-
Not that I know about. But Anthony may have some ideas. It might be nice for IM 7 to be able to things like that.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: How to get color information

Post by VanGog »

VanGog wrote:I thought you use fx
http://www.imagemagick.org/script/fx.php
to filter the output of txt:-
Note: This doesn't solve problem of performance, mentioned here:
viewtopic.php?f=1&t=21061&p=85345#p85345
Post Reply