1
$\begingroup$

I'm looking at someone else's piece of code:

Monitor[
  cnt = 1;
  Table[Export[ToString[cnt++],
    Show[orig, 
     ViewAngle -> (ViewAngle /. Options[orig])/(sectionsWide),
     ViewCenter -> {{1, 1, 1}/2, ImageScaled[{y, x}]}], "PNG", 
    Background -> None, ImageSize -> sectionSize {1, 1}],
   {x, 1 - sectionsWide/2, sectionsWide/2, 1}, {y, sectionsWide/2, 
    1 - sectionsWide/2, -1}],
  cnt];

In the third line, it appears to be exporting to strings named "1", "2", "3", etc. I checked Directory[] and see no such files. Nor in the notebook's directory.

The next piece of code attempts to assemble the results:

cnt = 1; exp = 
 ImageAssemble[
  Table[ImageTake[
    Import[ToString[cnt++], "PNG"], {1, sectionSize - 1}, {1, 
     sectionSize - 1}],
   {x, 1 - sectionsWide/2, sectionsWide/2, 1}, {y, sectionsWide/2, 
    1 - sectionsWide/2, -1}]]

So my guess is that exporting without an extension exports to virtual files. But I'm unable to find relevant information in the documentation for Export.

$\endgroup$
  • $\begingroup$ make the names like "SCRATCH"<>ToString[cnt++] to be easier to search for. $\endgroup$ – george2079 Feb 14 '17 at 12:33
2
$\begingroup$

The file extension has nothing to do with the file contents. It is merely a convention that a PNG file has a .png extension. You can give it any extension. You can rename an existing file to anything, including any extension you can think of, without changing its contents.

If you use

Export["file", data, "PNG"]

it will export in PNG format to a file named file. It uses the format specified in the third argument.

$\endgroup$
  • $\begingroup$ Ah, then there is another reason the files aren't exporting. Odd, I don't see any errors or message. I'll poke around. Thank you. $\endgroup$ – Andrew Cheong Feb 14 '17 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.