<?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: IOError trying to change PICTURE_ELEMENT sourceImage in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185426#M6291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hmm. The only way other you'd get that particular error message is if arcgis either could not find or could not open the image file.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can it cause a problem if I try to set the sourceImage to a different file format than was originally saved in the MXD, e.g. create a PICTURE_ELEMENT from a PNG and then set the sourceImage to a JPEG?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jun 2014 19:43:24 GMT</pubDate>
    <dc:creator>LucasScharenbroich</dc:creator>
    <dc:date>2014-06-19T19:43:24Z</dc:date>
    <item>
      <title>IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185422#M6287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This question is cross-posted &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://gis.stackexchange.com/q/102574/32605" rel="nofollow" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I recently ran into this issue after I published a Geoprocessing Task to a production server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My geoprocessing python code is an enhanced Web Map Print service that loads a map via the arcpy.mapping.ConvertWebMapToMapDocument function and either sets the sourceImage of a PICTURE_ELEMENT or moves it off of the page. The published GP Service works correctly on a development server, but returns the following error when running on the production server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Unable to complete operation. Error executing tool.:&amp;nbsp;&amp;nbsp; Traceback (most recent call last):&amp;nbsp; &amp;nbsp;&amp;nbsp; File "&amp;lt;ags_folder&amp;gt;\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\service.py", line 643, in &amp;lt;module&amp;gt; main() &amp;nbsp;&amp;nbsp; File "&amp;lt;ags_folder&amp;gt;\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\service.py", line 634, in main (message, output_file, image_files) = execute(web_map_json, output_format, layout_template, layout_template2, georef_info, quality) &amp;nbsp;&amp;nbsp; File "&amp;lt;ags_folder&amp;gt;\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\service.py", line 482, in execute staticLegend.sourceImage = legendPath &amp;nbsp;&amp;nbsp; File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\_base.py", line 87, in _set return setattr(self._arc_object, attr_name, cval(val)) &amp;nbsp; IOError: Cannot set path based on current settings. &amp;nbsp; Failed to execute (PythonWebPrint). Failed to execute (Python Web Print).&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the relevant python code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elements = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', "StaticLegend") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(elements) &amp;gt; 0: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the picture &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staticLegend = elements[0]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if web_map_object.has_key("staticLegend"): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staticLegend.sourceImage = legendPath &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Cannot actually delete things, so just move it off the page &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staticLegend.elementPositionX = -100&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have verified that the correct file path is being used, and that the file exists and that the folder and file permissions are identical to the MXD files being loaded by the arcpy.mapping.ConvertWebMapToMapDocument function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas as to the source of or how to fix this issue, or other diagnostics that I can perform?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 13:53:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185422#M6287</guid>
      <dc:creator>LucasScharenbroich</dc:creator>
      <dc:date>2014-06-19T13:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185423#M6288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does the map document have data-driven pages enabled? Is the picture element set to either 1) use a field as the image path or 2) use an attachment as the image source? If so, that is the reason you can't set the image path.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 16:12:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185423#M6288</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2014-06-19T16:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185424#M6289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Does the map document have data-driven pages enabled? Is the picture element set to either 1) use a field as the image path or 2) use an attachment as the image source? If so, that is the reason you can't set the image path.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Data Driven Pages are not enabled and the Picture Source is set to "Simple Path". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I did notice that the MXD on the production server had the "Save Image as Part of Document" option checked while the test server MXD did not. I unchecked that option on the production MXD, but received the same error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 17:13:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185424#M6289</guid>
      <dc:creator>LucasScharenbroich</dc:creator>
      <dc:date>2014-06-19T17:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185425#M6290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmm. The only way other you'd get that particular error message is if arcgis either could not find or could not open the image file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 18:35:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185425#M6290</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2014-06-19T18:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185426#M6291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hmm. The only way other you'd get that particular error message is if arcgis either could not find or could not open the image file.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can it cause a problem if I try to set the sourceImage to a different file format than was originally saved in the MXD, e.g. create a PICTURE_ELEMENT from a PNG and then set the sourceImage to a JPEG?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2014 19:43:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185426#M6291</guid>
      <dc:creator>LucasScharenbroich</dc:creator>
      <dc:date>2014-06-19T19:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185427#M6292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It shouldn't be an issue. I'd just sort of try some things at this point, one of which would be to save the image as a PNG. I'd also do&amp;nbsp; some diagnostic messaging just in case:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if web_map_object.has_key("staticLegend"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Setting legend to {0} -- is file? {1}".format(legendPath, os.path.isfile(legendPath)))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staticLegend.sourceImage = legendPath&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:24:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185427#M6292</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T09:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: IOError trying to change PICTURE_ELEMENT sourceImage</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185428#M6293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It shouldn't be an issue. I'd just sort of try some things at this point, one of which would be to save the image as a PNG. I'd also do&amp;nbsp; some diagnostic messaging just in case:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if web_map_object.has_key("staticLegend"): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Setting legend to {0} -- is file? {1}".format(legendPath, os.path.isfile(legendPath))) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staticLegend.sourceImage = legendPath&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Solved! The call to os.path.isfile was returning false, which put me on the right track.&amp;nbsp; The critical difference between the development server and the production server was that, on the production server, the folder of MXD templates is located on a different drive than the AGS install (Drive &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt; ).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although the relative path to the file was correct, it was not getting joined to the drive letter correctly, which caused python to look for the file relative to the current working directory of drive D:, as stated in python's os.path.join docs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The path that was created was "D: path\\to\\my\\image.jpg", but needed to be "D:\\path\\to\\my\\image.jpg".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all of your help; even though everything I had posted was not related to the underlying problem at all! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2014 17:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/ioerror-trying-to-change-picture-element/m-p/185428#M6293</guid>
      <dc:creator>LucasScharenbroich</dc:creator>
      <dc:date>2014-06-20T17:44:20Z</dc:date>
    </item>
  </channel>
</rss>

