Import/Export blueprints as PNG images

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Hexicube
Fast Inserter
Fast Inserter
Posts: 217
Joined: Wed Feb 24, 2016 9:50 pm
Contact:

Import/Export blueprints as PNG images

Post by Hexicube »

PNG and JPEG support storing arbitrary data, and additionally has support for text stored with deflate compression.
PNG's method: https://www.w3.org/TR/PNG/#11zTXt (iTXt could also work, storing the already-compressed string)

I'd like to be able to directly drag an image of a blueprint into Factorio, and have it become an actual blueprint without needing to open the blueprint screen and paste a string. This would be extremely intuitive with an image containing the relevant data, and Spore has already demonstrated that this can be done. Having blueprints represented with an image instead of of long string means you can see at a glance that you have the correct blueprint, and would also make browsing blueprints outside of the game a lot nicer.

I'm not sure if the added data would survive when uploaded to imgur, it seems to remove any "unnecessary" data from images when they're uploaded.

Roxor128
Fast Inserter
Fast Inserter
Posts: 168
Joined: Sun Oct 02, 2016 9:48 am
Contact:

Re: Import/Export blueprints as PNG images

Post by Roxor128 »

When you started covering this, I thought "That sounds just like Spore", and sure enough, you go on to mention just that.

Yes, aggressive block-stripping to save space is the curse of any program which uses custom PNG blocks. On the other hand, if they're used poorly they can result in rather large files, as at least one Adobe program I recall running across years back did. Fortunately, the Factorio developers seem like they'd be the sort to do it well.

AntiBlueQuirk
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Wed May 03, 2017 2:57 pm
Contact:

Re: Import/Export blueprints as PNG images

Post by AntiBlueQuirk »

I've always been really excited by the fact that PNGs can store arbitrary metadata, and this would be a great use for that feature.

However, another way to handle it, which would protect against metadata stripping is using Steganography, and encoding the data in the low bits of the image. As an example, this image contains it's own blueprint string:
out.png
out.png (21.63 KiB) Viewed 5670 times
In this image, I've actually gotten pretty aggressive, and stripped out the lower 4 bits of each color channel. That's half the color data! And yet, you can't tell at first glance that I've done it, because those lower bits only account for 1/16 of the output color value. At 276x140 pixels, I can store almost 58k of data in this image. The blueprint string for this blueprint is only 0.5k, so we have more than enough room. If we get conservative, and only remove the lowest bits of each color channel, we still have 14k of storage, which is enough space to store the blueprint string about 38 times over.

Now, if your image hosting site recompressed the image in a lossy format, the data would be lost. But if your hosting site does that, it almost certainly is going to strip the metadata too.

Also, this is cooler.

EDIT: Monaco actually encodes it's level images this way as well: https://www.facebook.com/notes/monaco/s ... 497056995/ Also, despite people's first thoughts, Spore doesn't use PNG chunks, it actually uses steganography as well. Spore also hashes the image data with the encoded data to prevent tampering. (Like showing one blueprint, but containing the string for a different blueprint. I'm not sure on the details.)
Last edited by AntiBlueQuirk on Sun Jun 25, 2017 11:57 am, edited 2 times in total.

Mr. Mechanic
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sun Jan 10, 2016 1:53 pm
Contact:

Re: Import/Export blueprints as PNG images

Post by Mr. Mechanic »

The only problem I see here is that blueprint images cannot easily be distinguished from normal screenshots, and that might cause some confusion. I think making the data obviously visible (by reserving a bunch of pixels for it) would be better.

AntiBlueQuirk
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Wed May 03, 2017 2:57 pm
Contact:

Re: Import/Export blueprints as PNG images

Post by AntiBlueQuirk »

Well, I just used a screenshot because it was easily accessible, but you could make the visible image anything you wanted to. You could make it look more like a blueprint, and include the name and icon. You could even just take a screenshot of the blueprint window, and use that! (Though you'd probably want to remove the useless UI elements.)

Voxatron uses a more visible format for it's cartridges, if you wanted to go that route: https://www.lexaloffle.com/bbs/cposts/0/cpost3922.png (The level data is at the bottom.)

AntiBlueQuirk
Long Handed Inserter
Long Handed Inserter
Posts: 69
Joined: Wed May 03, 2017 2:57 pm
Contact:

Re: Import/Export blueprints as PNG images

Post by AntiBlueQuirk »

Here's a better example of what it might look like:
out.png
out.png (45.96 KiB) Viewed 5657 times

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Import/Export blueprints as PNG images

Post by ssilk »

Added to viewtopic.php?f=80&t=45635 Improvements for the Construction-Phase (Handling of Blueprints / Ghosts / Copy / Pre-Configuration)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
teemu
Inserter
Inserter
Posts: 46
Joined: Tue Sep 20, 2016 10:08 pm
Contact:

Re: Import/Export blueprints as PNG images

Post by teemu »

Mr. Mechanic wrote:The only problem I see here is that blueprint images cannot easily be distinguished from normal screenshots, and that might cause some confusion. I think making the data obviously visible (by reserving a bunch of pixels for it) would be better.
Maybe some kind of border?
Attachments
blueprinty.png
blueprinty.png (33.19 KiB) Viewed 5528 times

Post Reply

Return to “Ideas and Suggestions”