<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: in_memory png to base64 string in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307933#M23969</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the code, that gives me some context. &amp;nbsp;Maybe try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;tiff = r'C:\Temp\my_tif.tif'&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;png = r'in_memory\my_png.png'&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;CopyRaster_management(tiff, png, pixel_type='32_BIT_SIGNED', format='PNG')&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;SPAN&gt;b64 = base64.b64encode(png.read())&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Regards,&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Feb 2017 21:13:41 GMT</pubDate>
    <dc:creator>TomSellsted</dc:creator>
    <dc:date>2017-02-24T21:13:41Z</dc:date>
    <item>
      <title>in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307928#M23964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone know how to convert an in memory png to a base64 string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My raster is defined as:&lt;/P&gt;&lt;P&gt;png = "in_memory\my_png.png"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then try to convert it:&lt;/P&gt;&lt;P&gt;import base64&lt;/P&gt;&lt;P&gt;base64_string = str(base64.b64encode(png))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;base64_string gets populated as: aW5fbWVtb3J5XG15X3BuZy5wbmc=&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which, when decoded is: in_memory\my_png.png&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...not exactly what I had in mind.&amp;nbsp; Is this even possible do do in a geoprocessing script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 18:39:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307928#M23964</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2017-02-24T18:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307929#M23965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had done something similar, but was loading an image file from disk. &amp;nbsp;To encode it I had to read it. &amp;nbsp;Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with open(driverPhoto, "rb") as imageFile:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; encodedPhoto = base64.b64encode(imageFile.read())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps you have to do a read as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 19:05:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307929#M23965</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2017-02-24T19:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307930#M23966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Good idea...however, python doesn't seem to want to open an "in_memory" raster:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Runtime error &lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;IOError: [Errno 2] No such file or directory: 'in_memory\\my_png.png'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 19:41:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307930#M23966</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2017-02-24T19:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307931#M23967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should already be open, I was suggesting that you read it. &amp;nbsp;Could you provide the code you have attempted?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 19:48:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307931#M23967</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2017-02-24T19:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307932#M23968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using arcpy.CopyRaster_management to copy a local tiff into an in memory png:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tiff = r'C:\Temp\my_tif.tif'&lt;/P&gt;&lt;P&gt;png = r'in_memory\my_png.png'&lt;/P&gt;&lt;P&gt;CopyRaster_management(tiff, png, pixel_type='32_BIT_SIGNED', format='PNG')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;f = open(png)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 21:06:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307932#M23968</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2017-02-24T21:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307933#M23969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the code, that gives me some context. &amp;nbsp;Maybe try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;tiff = r'C:\Temp\my_tif.tif'&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;png = r'in_memory\my_png.png'&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;CopyRaster_management(tiff, png, pixel_type='32_BIT_SIGNED', format='PNG')&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;SPAN&gt;b64 = base64.b64encode(png.read())&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Regards,&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 21:13:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307933#M23969</guid>
      <dc:creator>TomSellsted</dc:creator>
      <dc:date>2017-02-24T21:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307934#M23970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm surprised that it's possible to save a file in the in_memory workspace ending in '.png', although I see that you can. The file isn't actually .png format, though, it's a geodatabase raster (check the layer properties).&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/329416_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 21:18:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307934#M23970</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-24T21:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: in_memory png to base64 string</title>
      <link>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307935#M23971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're right Darren, I was getting thrown off by the png extension.&amp;nbsp; It's not actually a png, it's a geodatabase raster.&amp;nbsp; It looks like you can only store "raster" in the in memory workspace.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Feb 2017 21:36:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/in-memory-png-to-base64-string/m-p/307935#M23971</guid>
      <dc:creator>JasonLevine</dc:creator>
      <dc:date>2017-02-24T21:36:15Z</dc:date>
    </item>
  </channel>
</rss>

