So I'm using imagemagick to write PNG images, and it fucks them up.
Looking at them with xview makes it spit out the error PNG file: foo.png - Application must supply a known background gamma and the image does not display properly; it does stupid things like show a black background with nothing on it instead of the blue background with a white/grey image like I was expecting.
(Other applications do still display it correctly; it's fine in GIMP, and it's fine in any browser. This of course raises the subsidiary question of just why the pissing dog's cunt xview can't bloody guess a suitable default value for the "unknown" when every other sodding application doesn't have a problem with it. But xview is not the subject of this page, and the point is only really important in that the image is certainly broken at least in some sense, and therefore there exists the possibility that some other obscure application that I don't know about might also throw wobblies about it.)
It's not the original image itself being fucked. It even does it on what ought to be nothing more than a simple copy operation. Just doing convert bar.png foo.png - where bar.png is an image saved from GIMP, that causes no problems at all - nevertheless results in a foo.png that throws the above error and is buggered. It's definitely imagemagick itself deciding to fuck up the image for no sodding reason at all.
Inspecting the new foo.png in hex reveals that as well as rearranging stuff later on in the file, it inserts 16 bytes near the beginning which begin with the string gAMA. Since the error message refers to "background gamma", and there is no such sequence in the original bar.png, this looks like it could well be something to do with the problem.
So the obvious thing to do is to try and discover what option needs to be given to stop imagemagick putting this cunting thing in at all, since it obviously isn't fucking needed as the original file works fine without it. Or at the least to make it give the bastard a value which isn't "unknown". I mean what the steaming fuck is it playing at? What the fuck is the point of putting the fucking thing in when you don't fucking need it, and if it must put it in, why the dribbling dog diarrhoea does it put it in with an invalid value? Stupid cunting shite. If you can't do it properly then don't fucking do it at all.
But this is easier said than done. You might think, for instance, that imagemagick has an option like -background-gamma - which would be logical, after all - or something of the kind. It does not. (Or if it does, it is fucking well hidden.) It does have a -gamma option, but that's for something different. There don't seem to be any background-related options that concern gamma at all, nor any gamma-related options that concern the background. I suppose that makes sense in one way, since why the crusty spunk stain should a single layer image even have a "background" in the first place, let alone one with a different gamma to the rest of it? That would not make sense. But it also does not make sense that imagemagick should nevertheless try and write the image like that, and fuck it up by default, and not provide an option to unfuck it.
And the trouble is that this error is NOT "search-engine friendly". Searching for the exact error message is completely useless, since all it finds is bits of source code where the string is defined... ah, and the source code is for imagemagick, not xview. So xview is using that bit of imagemagick's code, and what we have here is a case of two applications that can't work together properly even though they use the same fucking codebase. I mean, chicken's tits, who wrote this bollocks?
Reducing the search term to simply background gamma doesn't help either, because then you just get swamped with shitloads of references to background gamma radiation and you can't find fuck. Trying to exclude radiation from the search and adding more image-specific terms doesn't really help - you just get the same useless results as for the exact error message, plus more crap about using gamma radiation for imaging (fucksake).
So quite how I did manage to eventually find an answer I already can't remember, but now that I have, here it is:
-strip
You insert that right before the output filename on the imagemagick command line, and lo and behold, it prevents it from putting that stupid incorrect value in the output file. So it goes like this:
convert bar.png (other stuff goes here) -strip foo.png
Apparently it does not work if you are using the -gamma option with a value other than 1/2.2 (who comes up with these stupid fucking numbers?), but I haven't tried that so I can't comment.
Anyway, there it is, and hopefully this page will now start showing up in people's search results so they can find what they need to know straight away instead of spending half an hour screaming and swearing at the flood of useless shit they find instead.
Back to Pigeon's Nest
Be kind to pigeons