mathematica中的图像导出和导入不连贯

问题描述 投票:3回答:1

大家新年快乐!

我在Mathematica 11中运行以下代码但我无法理解输出。 b和b1具有相同的大小,并且以字符显示时看起来相同,但Mathematica对它们的看法不同。你能就这为什么会这样给我一些建议吗?

a = Import["ExampleData/rose.gif"];
b = ExportString[a, "PNG"];
c = ImportString[b, "PNG"];
Export["D:/flower.txt", b];
b1 = Import["D:/flower.txt"];
ByteCount /@ {b, b1}
b == b1

最好的祝福!

image import export wolfram-mathematica
1个回答
4
投票

要导出到文本,您需要字符串形式的b。转换为PNG和Base64有效。

a = Import["ExampleData/rose.gif"];
b = ExportString[a, {"Base64", "PNG"}]
c = ImportString[b, {"Base64", "PNG"}]
Export["D:/flower.txt", b, "String"];
b1 = Import["D:/flower.txt", "String"];
ByteCount /@ {b, b1}
b == b1
{41016, 41016}
True

新年快乐!

© www.soinside.com 2019 - 2024. All rights reserved.