Scaling Images in Java and Kotlin

Published at 08:09 on 18 July 2020

It’s sort of confusing. There’s a lot of ways to do it. And by “a lot” I mean a lot.

Despite the range of options, my initial attempts at downsizing images were disappointing, yielding ugly results. As an example, consider this:

To fully appreciate how bad that is, here’s what Gimp produces when asked to do the same thing:

Yes, the same thing. In both cases, I am requesting the image be scaled with the bicubic algorithm. Clearly, there is more processing going on in Gimp than simply bicubic scaling. Despite my attempts, I kept getting this sort of disappointing result as I experimented with the various ways of doing it.

Finally, I ran across a magic combination of API calls that yields acceptable results:

val nWidth = (imageIn.width * ratio).toInt()
val nHeight = (imageIn.height * ratio).toInt()
val imageOut = BufferedImage(nWidth, nHeight, imageIn.type)
imageOut.createGraphics().run {
    drawImage(imageIn.getScaledInstance(nWidth, nHeight, BufferedImage.SCALE_SMOOTH), 0, 0, null)
    dispose()
}

That code produced the following:

Not quite as good as what Gimp yields, but close. The takeaway is that getScaledInstance does at least some necessary extra processing, above and beyond the standard scaling, which is needed to produce acceptable results. I probably wouldn’t want to use it for high-resolution production work, but for generating screen-resolution images for sharing on the Web it’s perfectly adequate.

Update: Some more research reveals that getScaledInstance  with BufferedImage.SCALE_SMOOTH doesn’t use the bicubic algorithm after all; it uses an area-averaging algorithm which is even slower. Those details are mostly irrelevant, however: the important thing is that for my application, it delivers acceptable quality in an acceptable amount of time, which is more than can be said for all the other API calls.

Phantom Menace, Part II

Published at 11:46 on 5 July 2020

Recently, I wrote:

We also have the threat of right-wing terrorism, or should I say the virtual certainty of it. The American Right is an overall fascist political movement. Fascists believe in seizing power ruthlessly, and that nobody but themselves have any business being in power (or even are fully proper members of the nations they reside in). (One only has to consider the trope, long present amongst right-wingers, particularly rural ones, that they are the “real Americans” and theirs is the “real America.”) They also have guns, and lots of them. There is really only one logical takeaway from all this, and that is that they will start using those guns to fight those whom they believe unworthy of ruling the nation.

Right-wing domestic terrorism is already the dominant variety in the USA. Well, you ain’t seen nothing yet.

At that point, we will have a national domestic security crisis. The logical response to that will be to enact new measures aimed at targeting and suppressing the violent subversives.

So as to avoid cluttering up that article with a digression, I left out the point that the menace from those domestic-security measures will not be merely a future one, when a fascist takes power. Far from it: the temptation will be nearly as great for Biden to use them against the radical left as it will be against the far right.

This is the case, even in the absence of any equivalent proclivity towards political violence on the part of the American left. That is merely a fact, and facts and logic often prove little or no obstacle to the exercise of political power. Authoritarianism is, at its core, both illogical and highly destructive, yet this has done little to prevent it from being exercised throughout history.

The Democratic Party has plenty of centrists in it, Biden is himself one of those centrists, and he is likely to appoint many centrists as his advisers. Targeting both ends of the political spectrum is just the sort of thing that a centrist (who believes both sides to be approximately equally off-base as a core part of his or her weltanschauung) would find inherently appealing.

So the centrists, self-professed enemies of authoritarian extremism, might themselves get suckered into becoming precisely the sort of enemies of liberty they believe to be defending against.

They are, in fact, uniquely vulnerable to it.

As a left-wing anarchist, I have had to contend with the unpleasant fact that anti-capitalist revolutions have a sad record of creating, not greater liberty and equality, but greater tyranny. As a person opposed to both capitalism and authoritarianism, I have been compelled by my beliefs and my knowledge of history to explore the pitfalls that led revolutionaries astray. I am hardly unique; such interests are common amongst anarchists.

They are not nearly so common amongst centrists, securely ensconced in their firm and deeply-held emotional attachment to both-sides-ism. Most centrists are well aware of the Terreur (and will eagerly base sermons to radicals around it), yet blissfully ignorant of the Semaine Sanglante (where in a week at least as many were slaughtered in the name of keeping society safe from radicalism as the former did in ten months).

In the application of the security measures, therefore, there is every reason to be concerned that centrists will be smug, cocksure, and ignorant. That is a dangerous combination of characteristics, to say the least.

The Phantom Menace

Published at 07:50 on 3 July 2020

Let’s be optimistic and assume that Biden wins in November and is allowed to take office in January. If so, we may well be heading into a period of history which will later prove to have been a battle with a mostly phantom menace, one which let a real menace grow and fester.

The phantom menace would be the power of the political right to frustrate Biden’s agenda, and the real menace would be the continued dismantling of checks and balances against autocracy, particularly the continued growth of the imperial presidency.

On that latter point, what simpler and easier way to counter the opposition than for a Democratic president (one with a popular mandate behind him, unlike the opposition) to assert his prerogative to continue the decades-long growth of the power of the presidency at the expense of the other two branches of the Federal government? Obama did it, and in doing so unwittingly helped create the monster that is Trump.

Then there is the Senate and its antimajoritarian traditions to contend with. The Democrats chipped away at those during the Obama Era, too, only to bitterly regret it later. If the Democrats take the Senate (as they might) they almost certainly will not earn a filibuster-proof majority, so the temptation to dismantle the filibuster will then likely prove too great to resist.

We also have the threat of right-wing terrorism, or should I say the virtual certainty of it. The American right is an overall fascist political movement. Fascists believe in seizing power ruthlessly, and that nobody but themselves have any business being in power (or even are fully proper members of the nations they reside in). (One only has to consider the trope, long present amongst right-wingers, particularly rural ones, that they are the “real Americans” and theirs is the “real America.”) They also have guns, and lots of them. There is really only one logical takeaway from all this, and that is that they will start using those guns to fight those whom they believe unworthy of ruling the nation.

Right-wing domestic terrorism is already the dominant variety in the USA. Well, you ain’t seen nothing yet.

At that point, we will have a national domestic security crisis. The logical response to that will be to enact new measures aimed at targeting and suppressing the violent subversives.

Meanwhile, it is highly plausible that the Republican Party will continue to be a fascist party. Fascism of the Trumpist variety is still quite popular within its base, and it while it is possible that a big humiliation at the polls will prompt a recalculation (and the GOP falling into the hands of Never Trumpers), it is hardly certain this will be the case. Moreover, Trump is not an anomaly; the GOP had been trending fascist well before Trump came on the scene; reversing such a trend is going to prove harder than purging the party of one particular corrupt con-man’s influence.

A de-Trumpified GOP would be an improvement, mind you. It’s just that it would still be a danger; it would represent a return to the status quo ante Trump, and that status quo has been demonstrably shown to be vulnerable to a fascist takeover.

As such, another fascist presidency remains highly likely, and once it happens, odds are that president won’t be as incompetent as the current one is. (That incompetence has been the sole saving grace about Trump; Hitler, Mussolini, Franco, and so on were much more effective at consolidating power than Trump has ever been.) This gives us the worst of both worlds: a more competent and ruthless fascist taking the helm of a Republic whose guardrails have been further weakened, and with a package of anti-subversion legislation in his toolbox with which to use against the left.

What’s particularly perilous in all this is that there is not necessarily always an easy way out. Consider the Senate filibuster: absent dismantling it, it is likely that Biden will prove to be a failed president, unless he asserts unitary executive power to a degree that makes the dangers of scrapping the filibuster pale in comparison. And if Biden is a failed president, the most likely result is that fascism comes roaring back and liberty dies.

Thus, in the name of not going morally bankrupt today, a loan of political capital, one which makes going morally bankrupt in the future when it becomes due more likely, will be taken out.

All I can say is: Beware the phantom menace.

Who Were the Perpetrators?

Published at 22:15 on 2 July 2020

So, CHAZ/CHOP is no more. This is very much not a surprise; anyone with so much as half a brain could see it coming as soon as the pattern of shootings and the reportage on them became evident.

Not only were there multiple shootings, many of them fatal, at regular intervals, but they were reported as all being in or associated with the CHAZ/CHOP zone, even though at least half of them were not in fact inside the CHOP zone but merely in the same neighborhood as CHOP.

More significantly, information on the perpetrators of the shootings has, up until recently, been basically non-existent. That’s a huge information deficit. Absent any knowledge as to who the shooters are (and what their motives were), it becomes basically impossible to take away anything in the way of an informed conclusion from the shootings.

To understand why, consider the possibility that the police were involved somehow, either directly (we don’t know who the perpetrators were, so we can’t say that off-duty or plainclothes cops are not involved) or indirectly (i.e. the shooters weren’t cops but were encouraged by them) as part of a plot to discredit CHAZ/CHOP.

I do not think it is possible to rule this scenario out with any great degree of certainty, given all that has become known about the pervasive institutional corruption of policing in the USA. I think it can safely be assumed that neither the mayor nor her chief of police are involved, but it is not necessary for either to be involved; any such conspiracy could easily be lower down. In fact, it’s more plausible for it to be so, because it would make for a smaller conspiracy, and smaller conspiracies are easier to keep secret.

It is important to state at this point that all the above is mere conjecture and I have no hard evidence whatsoever to suggest that it is the case. The rub is, the narrative that the shootings are all directly the fault of the protesters also has no hard evidence in its favor, given the almost total lack of information about perpetrators and motives.

The above is the maximally-damaging plausible scenario for the Establishment. A somewhat less-damaging scenario for it is that the shootings are mostly the work of violent right-wing extremists set on discrediting the movement.

Note that (in contrary to the Establishment narritive that it’s the protesters fault) there is actually some evidence in favor of the right-wing extremist conjecture. (Note also that it is not incompatible with the police-corruption conjecture; it is plausible that corrupt cops could have reached out to right-wing extremists and encouraged them.)

Bottom line here is not to be squarely in favor of any of the scenarios above, as all the puzzles are missing a lot of pieces, only to point out that the Establishment narrative (that the zone was a shit-show that had to be ended) is itself one of those puzzles missing most of its pieces, and that to accept it on face value is to fall for Establishment propaganda.

On Testing, Trump Says the Quiet Part Loud

Published at 11:35 on 22 June 2020

He’s now all but admitted that his regime deliberately slowed down COVID-19 testing for political purposes.

Of course it did. It’s something that made sense to suppose was happening at the time (i.e. February and March), because they USA was doing such an astoundingly bad job at testing that it was hard to chalk it all up to mere random chance.

Remember, community spread in the USA was first detected in Seattle, for the simple reason that Dr. Helen Chu, a researcher Fred Hutch, decided to ignore the regulations and conduct unapproved testing for COVID-19 anyhow. And then there’s the strange and (otherwise mystifying) decision for the Trump regime to develop its own testing, during a crisis, when time is critical, even though the WHO was distributing a test that was already successfully being used in the rest of the world.

Yes, it’s that bad.

So, the most logical answer to the question “Is Trump really meaning it when he talks about deliberately slowing the pace of testing?” is: “Yes he is and yes he did.” It is the answer that jibes best with observable reality.

Linux: Still Linux (Alas)

Published at 11:58 on 21 June 2020

Mind you, I’d really like it if I could wholeheartedly endorse Linux as an alternative to Windows or MacOS for a general-purpose desktop operating system. But I just can’t.

Linux is great for some things. Servers, for instance. I run a Linux server at a colocation site for a variety of purposes. It was basically a no-brainer: it’s a rock-solid server OS. Linux on the desktop has improved to the point that for basic use (e.g. browsing the Web, reading email, maybe typing a document or two, or downloading and editing digital photos) it is now a totally viable alternative to Macs or Windows.

The problems happen when one moves beyond basic desktop use: one all-to-quickly ends up in a maze of twisty little passages of UNIX system administration arcana. Hardware support, in particular, seems to be a bane of Linux. I couldn’t even get one of the most common digital radio interfaces running with one of the most common ham radio applications on one of the most common desktop Linux distros!

Yes, yes: there’s distros expressly designed for ham radio. Well, what if I want to use that computer for more than just ham radio? I’m S-O-L, that’s what: instead of delving into system arcana trying to get ham software working, I’ll doubtless be delving into system arcana trying to get normal desktop productivity software running.

In fact, the very existence of such ham radio-specific distros puts the lie to the claim that Linux interoperates well with ham radio hardware. If Linux did interoperate well, it wouldn’t be necessary to create such specialized distros in the first place! (Why create a specialized distro, if all one needs to do is install a few packages and make a few quick, easy tweaks to a mainstream distro?)

Then there’s my experiences with the Raspberry Pi. Not having an HDMI monitor, and not wanting to clutter up my limited space with one, I opted to order a serial interface cable with my Pi. It worked: the Pi booted and used the serial console when I connected it. Until they “upgrade” the Raspbian distro to remove that feature, that is, and fail to properly document how to re-enable it. After pissing away half a week trying to get the thing to boot on the serial console, I give up.

Forget it. I retired from systems administration because I was sick of it. Doing systems administration for “fun” as a “hobby” holds precisely zero appeal for me. If it doesn’t work with a modicum of effort on my part, I’m simply not interested. Ham radio is the hobby. Linux systems administration is not.

Linux has definitely gotten better as a desktop system over the years, but it’s still not fully there. Sorry, fanboys.

So, What Next?

Published at 11:10 on 10 June 2020

When it comes to social revolution, the ball is at this point pretty much in Trump’s court. He’s backed down, to the point of taking the temporary wall down (and the Smithsonian is saving some of the protest art added to it for its archives, which should give some indication at how significant historians believe this era is likely to prove).

So it goes. As I wrote earlier, politics is war by other means, and in war one is never in complete control of the situation.

The question is: what does Trump do next? He is an idiot, so he could well do something monumentally stupid that once again puts him in an extraordinarily weak position. The only thing to do is wait, see, and be ready to pounce if the opportunity once more arises.

At the very least, Trump is continuing to tank in the polls, making it increasingly likely that another big blue wave is coming and will sweep him out of office.

The above may in fact prompt the next revolutionary opportunity. What happens if Trump refuses to honor the result of that election? It is, in fact, more likely than not that he will so refuse. It is totally in keeping with his character, much more so than conceding defeat would be.

It is also possible that the total overall effects of the uprising that is now winding down have yet to materialize. If Trump’s popularity continues to decline, a tipping point may be reached where his Congressional allies turn on him. At that point, his rule has been so lawless that any number of things could form the basis for a second impeachment, one which this time would succeed.

Who knows? As for now, we are in wait, see, and be prepared mode.

Surprisingly, Trump Blinked

Published at 00:09 on 8 June 2020

It is difficult to imagine the stuff the generals said to him to get him to reconsider. They will now have to repaint the Oval Office walls, since that rhetoric stripped the paint from them.

They Seem to Be Blinking

Published at 15:47 on 5 June 2020

The Pentagon is backing off a bit. More then likely, Esper realizes how vulnerable his side is. More than likely, there has been private pushback from active officers that makes the public pushback from retired officers (of which there has been no shortage) look tame by comparison.

The question is, what happens after Esper is fired. Make no mistake, he will be fired. He has gone against the orange god-king’s wishes.

My guess at this point is that the clock is going to start running out. For a variety of reasons, these protests have been many things, but a good (or even an incomplete and halfhearted) implementation of social distincing they have not been. I may expound more on this aspect later, but the important fact right now is that the virus doesn’t care about what’s personally important to you.

It doesn’t care, because it can’t care. It’s a virus. It can infect people via protest rallies as easily as it can infect them via church services. As such, a big spike in cases is coming, and sooner rather than later. There is about a two-week incubation period for COVID-19, and we are now at day eleven of the protests.

The virus will therefore soon do what Grandpa Ranty has been unable to do by angrily tweeting and making shows of force, i.e. quell the energy in the streets. The window for revolution (which really does exist) will close and pass.

Such is life. Politics, to invert von Clausewitz, is war by other means, and in war one is never totally in control; so much of it depends on what one’s enemy does, and what happens in the overall environment.

One thing it does mean is that the unexpected economic uptick last month is likely to prove itself a blip and not the start of a trend. Not only is there going to be a resurgence in the pandemic, there are also many fatally wounded but not yet defunct businesses which will inevitably fail in the coming months.

Ideology Blinds Us: Resist

Published at 13:15 on 5 June 2020

Eric Arthur Blair (more commonly known by his pen name, George Orwell) is one of my favorite political authors, and his essay Notes on Nationalism is perhaps my favorite essay of his.

One of the things Orwell does in that essay is to list a set of facts which are both indisputably true, yet impossible for the adherent of a given ideology to acknowledge. In that spirit, here are two indisputably true recent facts, one which it is impossible for most radicals to acknowledge, the other which it is impossible for most liberals to acknowledge.

Radicals

It will be demonstrably better to face the prospect of agitating for a better society under a Biden Administration than it would under a second term of the Trump Administration. Furthermore, there is not currently anything near the level of political consciousness or organization to attempt anything like an anarchist revolution in the near term. The choice really is between Biden or Trump. As such, it should be our duty to see to it that Biden replaces Trump.

Liberals

It took over a week of nationwide unrest, unrest that rose to the level of rioting, for the State of Minnesota to (reluctantly) arrest and press charges against the three officers involved in the extrajudicial execution of George Floyd to merely be charged and arrested. That is in a state controlled by Democrats, whose Democratic Attorney General is a darling of the progressive left (i.e. is about as far to the left as you can be in the USA and still get elected). This shows how fundamentally rotten the system is, and how merely electing the right sort of people in and of itself offers no hope for significant change. It also shows how political unrest, including rioting, can have positive outcomes, outcomes that would have almost certainly not happened absent the unrest.

There Is No Contradiction

Part of the problem may be a failure to think fearlessly. At first, I think it appears to many that there is a contradiction between these two facts. Therefore obviously only one of them can be true, and it is personally convenient to conclude that the untrue statement is the one that challenges your viewpoint.

But there is no contradiction. The choice is not between electing Biden and being satisfied with that versus pressing for more fundamental change using means outside those of electoral politics. One can do both.