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.
Import/Export blueprints as PNG images
Moderator: ickputzdirwech
Re: Import/Export blueprints as PNG images
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.
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.
-
- Long Handed Inserter
- Posts: 69
- Joined: Wed May 03, 2017 2:57 pm
- Contact:
Re: Import/Export blueprints as PNG images
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:
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.)
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:
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.
-
- Burner Inserter
- Posts: 19
- Joined: Sun Jan 10, 2016 1:53 pm
- Contact:
Re: Import/Export blueprints as PNG images
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.
-
- Long Handed Inserter
- Posts: 69
- Joined: Wed May 03, 2017 2:57 pm
- Contact:
Re: Import/Export blueprints as PNG images
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.)
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.)
-
- Long Handed Inserter
- Posts: 69
- Joined: Wed May 03, 2017 2:57 pm
- Contact:
Re: Import/Export blueprints as PNG images
Here's a better example of what it might look like:
Re: Import/Export blueprints as PNG images
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...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Re: Import/Export blueprints as PNG images
Maybe some kind of border?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.
- Attachments
-
- blueprinty.png (33.19 KiB) Viewed 5528 times