flak rss random

the png that squished really big

I posted a tiny png, a mastodon stepped on it, and... it got really big.

background

Every web site needs an icon. Conveniently, the current fashion is to toss a letter or two in a square and call it a day, which is something even I can do. My technique is to open the web site in a browser and fiddle with the style and positioning until something aesthetically passing appears. Then I take a screenshot and crop down to icon size. This has the desirable property that colors always match, and at least on my screen, so do the fonts.

I use a command line something like this:

convert honk.xwd -crop 128x128+800+200 honk.png

This has always seemed to work. Produces a result that looks something like this:

honk.png

And the file size was 1137 bytes, which complies with current website obesity guidelines.

embiggening

I posted such an image where a mastodon could see it, the mastodon dutifully snoofed it up, and then rehosted it, except it was really really big.

Upload: atinyhonk.png

Download: reallybighonk.png

OK, it’s not that big, bytes wise. Still only 4811 bytes. But now the dimensions are 2560x1426. The intended image is hiding in there somewhere, if you scroll to right. What happened?

magick

Obviously, the original screenshot dimensions were stored somewhere in the file. I didn’t know that was possible, and it’s not officially a thing. But ImageMagick, from which I used the convert utility, stores its own meta data in the file. Most programs will ignore it, but if another ImageMagick using program, such as mastodon sees it, well... kaboom.

This is all there in the manual. Reading the documentation for crop one comes across a section about repaging the virtual canvas, with this delightful line. This is of course the result new users of IM would normally have expected from the "-crop" operator. Hey, that’s me!

So my bad, not reading the manual. But I’m curious why mastodon would want this behavior either. What are the circumstances in which somebody posts a cropped image to the mastoverse and they desire it be uncropped for federation? Reencoding uploaded images to strip metadata and eliminate potential exploits seems like good practice, but that’s not quite what happened here. The metadata was used to alter the image.

lessons

Well, if you didn’t know I use a 2560x1440 desktop with a 14 pixel dwm header, now you do.

Beware hidden metadata.

When you ignore and remove hidden metadata, don’t do the opposite of ignoring it.

Posted 16 Apr 2019 17:33 by tedu Updated: 16 Apr 2019 17:34
Tagged: software web