The Eclectic Quill

Website of Joshua McGee

By

Measuring the diameter of a circle in ImageMagick

If you have an image (or crop of an image) that contains just a circle against a solid background of a contrasting color, you can measure its diameter with the ImageMagick command line tools.

Let's generate an image to test it:

convert -size 400x400 xc:skyblue -fill white -stroke black -draw "circle 260,220 280,340" circle.png

That generates this image:

What are the dimensions of that circle?  Run this command:

convert circle.png +repage -fuzz 5% -trim +repage - | identify -format '# %wx%h\n' -

You get this output:

# 245x245

If the numbers on the sides of the x are not within 1px of one another, change the value of fuzz, marked in blue in the code above.  If it is a lossless image format such as PNG or GIF, make it 0%.  If it's a JPEG, try increasing it.  Once they are within one pixel, you have identified the circle's diameter: in this case, 245 pixels.

That is because, internally, you have created this trimmed image:

By

Happy 82nd Birthday, Carl Sagan!

carl-sagan-one-world-quote-2-r

We humans are one species and this is our world — Carl Sagan, 1934 – 1996

By

It is not “intolerance” to oppose Trump and his supporters

It is all the rage in some conservative circles online to point at people who oppose Donald Trump, or who oppose supporters of Trump, and say "Look at you, preaching tolerance all the time, and now you show that you are nothing but a bigot!"

OK.  Let's break this one down.

"Tolerance", properly construed, is merely a convenient shorthand for recognizing the humanity of others and their right to carry on in any fashion that does not actively harm another person.  It is not magnanimity to "tolerate" gay people, or fat people, or people in wheelchairs, or people with a different skin color — rather, it is an act of wickedness to ostracize them.

Likewise, no one argues that we should tolerate a man who is assaulting someone in the middle of the street.  It is an immoral act to permit an assault — when you prevent violence, you are not denying a man his right to harm others, you are supporting his victim's right not to be subjected to violence.

I would go a step further: it is an immoral act to tolerate someone who stands by and watches a man commit violence against another human being without attempting to intercede, let alone someone who cheers that man on.  Such a person is not expressing a simple difference; such a person is enabling an unjust act.  And that gets us to Trump and his supporters.

No, I will not "tolerate" Donald Trump.  No, I will not "tolerate" your right to support Donald Trump.  To do so would, itself, be an injustice.  Trump is — with every breath and every joke and every grope — degrading and insulting and injuring and threatening and violating our fellow citizens.  To oppose him, and the people who enable him, is not called "intolerance".  To oppose them is called "morality".

By

Just when you thought you had mastered cross-browser testing…

Just when you thought you had mastered cross-browser testing, emoji come along

Just when you thought you had mastered cross-browser testing, emoji come along

By

What disqualifies a Priority Mail flat-rate envelope?

A USPS Priority Mail flat-rate envelope will ship for a fixed price, regardless of its weight, "up to 70 pounds".  Neat.  But hold on:  seventy pounds?  How much can those things hold?

I checked the Domestic Mail Manual.  You are allowed to reinforce the seams and the seal with tape, but unless the envelope is slim enough to seal with its own adhesive, it is ineligible for flat-rate service.  So what's the maximum volume you can fit in there?

I estimated with a stack of copy paper.  The envelope will close around a 1.9cm stack.  Any more than that, and it's too thick.  But Priority Mail envelopes are slightly longer than a sheet of copy paper.  As a rough (but generous) estimate, if you are constrained to a rectangular prism, you can maybe fit something that is 1.9cm x 22cm x 30cm into one.  That's 1250cc, or 0.00125 cubic meters.

That's 0.00125 m3 that is allowed to weigh 32kg, mind you.  This means that the item you are mailing can have a density of 25,600 kilograms per cubic meter and still be permissible.

So I turned to The Engineering Toolbox, copied the alloy density table, pasted it into Google Sheets, and sorted it.

A slab of solid aluminum has a typical density of 2712 kg/m3.  But forget that.  Aluminum is light.

How about steel?  7850 kg/m3.  That's more than a factor of four.

Copper?  8940 kg/m3.  Still a factor of four.

Fine, let's pull out the big guns.  I want to mail you a slab of lead in a Priority Mail envelope.  That would be 14kg, or 31 pounds.

OK.  Gold.  A hefty 53 pounds.

Let's scroll to the bottom.  There we go:  iridium!  I want to mail you a 1.9cm x 22cm x 30cm slab of prone-to-shattering iridium in an unpadded cardboard-and-plastic-tape envelope.  So I go out and pay the seventeen thousand dollar spot-price for a slab of iridium, stick it in a Priority Mail envelope, add some packing tape to reinforce the seams (better safe than sorry), insure it for the maximum $500 (because I'm not an idiot, obviously), and take it to the Post Office.  They place it on the scale.  And it would weigh ... under 62 pounds.  It's mailable.  I could even include a little thank-you-for-your-business note and it wouldn't take it over the seventy-pound mark.

So watch your mailbox.  It's possible that you'll be getting a seventeen thousand dollar slab of iridium in a Priority Mail envelope from me.

I mean, it's not likely.  But it's definitely possible.