Graphics are tightly integrated into the Mathematica interface. The Front End is programmable, and Mathematica has functions to interface with the web, so the question naturally comes up:

Could we make it possible to upload images to StackExchange directly from Mathematica, using a palette button, and without the need to first save them to disk?

See the answer below for an implementation!

share

1 Answer 1

up vote 87 down vote accepted

Update:

The uploader is fixed now! We had to turn it into a full Mathematica application in order to adapt to the changed SE API. The new version and installation instructions can be found in the SEUploaderApplication repository of halirutan. If you are not able to install it through the provided installation script, please download the complete repository, unpack it and copy the SEUploader folder (with all its content) into

FileNameJoin[{$UserAddOnsDirectory, "Applications"}]

After a restart of Mathematica, the "SE Uploader" should show up in the "Palettes" menu. If you still have problems, leave a @halirutan comment here stating your operating system, Mathematica version and the occurring error. --halirutan


25. November 2013

StackExchange has changed the upload API. I have adapted the image uploader to work with the new API. Please follow the instructions on the SEUploaderApplication repository. --halirutan


Original Post

This is my implementation (with contributions from @halirutan and help from a number of people) of an image uploader palette, which I would like to share with the community to make it more convenient to use this site.

USAGE:

  • When correctly installed, you should see a palette like this:

    enter image description here

  • To upload, just select a graphics (or any other part of the notebook), and press the "Upload to SE" button to get a preview before uploading:

    enter image description here

    On Windows there are two buttons: "Upload to SE" and "Upload to SE (pp)". The "pp" (pixel perfect) one will rasterize the selected notebook element exactly the same way you see it in the notebook. Unfortunately I haven't (yet) been able to make this work on platforms other than Windows. The "Upload to SE" button will reformat everything to a width of 650 pixels and will discard any style/magnification information.

  • You can also see the history using the "History..." button. This will show you your recent uploads and you can click on an existing image to copy its URL or clear the history.

    enter image description here

  • To update, simply use the Update... button. If there is an update available, this button will turn pink. The palette automatically checks for updates every few days (if it is open).

  • You can also watch a screencast showing how to use the palette.

BUG REPORTS, SUGGESTIONS, DEVELOPMENT:

Ideas, suggestion, code improvements, problem reports are most welcome! Pease use the GitHub bug tracker for bug reports or feature requests. Just comment on this post for anything else.

The source code is available through GitHub.

Feel free to fix problems yourself and send pull requests. This can even be done through the GitHub web interface.

KNOWN ISSUES

There are a few problems that have happened to people, but I am not able to reproduce them. If you can come up with a way to reproduce any of these, please contact me!

  • Sometimes none of the palette buttons do anything. Pressing Update or History will not bring up a new window either.

    If this happens to you, close the palette and re-open it from the Palettes menu. If that doesn't fix the problem, then open the palette, evaluate SEUploader`checkOnlineVersion[], then close and re-open the palette.

  • Sometimes no palette buttons show at all, just the Mathematica.SE logo on the left. If you can reproduce this, please contact me.

  • The thumbnails of old uploads (upload history) may get corrupted for reasons unknown to me. The symptom is an error or hang when you press the History button or an error every time you try to upload. To fix this, first try clearing the history in the History... dialog. If the front end hangs when you try to open the History window, clear the history as follows:

    1. Close the palette and restart the Front End

    2. Identify the file name of the palette. It's found here: SystemOpen@FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "Palettes"}]. Let's call it SE Uploader.nb.

    3. Evaluate CurrentValue[$FrontEnd, {"PalettesMenuSettings", "SE Uploader.nb", TaggingRules}] = {} and restart the front end. Make sure you use the correct file name for your system in place of SE Uploader.nb. Only use the file name, not the full path. Alternatively this front end option can be cleared using Format -> Option Inspector after selecting Global Preferences in the top left dropdown.

    4. Restart the Front End again, open the palette and check that the History... button brings up an empty window. If the problem was due to corrupted history entries, it should be fixed now.

  • When running in HiDPI mode on OS X, there may be a thin line on the right edge of uploaded images.

UNINSTALLING

If you used the suggested method to install the palette, the following will remove it completely and clear all settings. This is useful if you are having problems with the palette and want to try reinstalling it.

Close the palette, then evaluate the following:

DeleteFile[FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "Palettes", "SE Uploader.nb"}]]

CurrentValue[$FrontEnd, {"PalettesMenuSettings", "SE Uploader.nb"}] = {}

CurrentValue[$FrontEnd, TaggingRules] = DeleteCases[
  CurrentValue[$FrontEnd, TaggingRules], 
  "SEUploaderLastUpdateCheck" | "SEUploaderVersion" -> _]

Now restart the front end (quit Mathematica completely).

share
    
Works marvellously, thanks for all the hard work! –  István Zachar Oct 1 '13 at 18:50
    
I have a problem win Windows 8.1 64 and Mathematica 9 or 10. I receive the message "PrependTo::normal: Nonatomic expression expected at position 1 in PrependTo[CurrentValue[SEUploaderPrivatepnb, {TaggingRules, ImageUploadHistory }],..." after the image has been uploaded... –  unlikely Jul 18 at 11:44
    
Since Mathematica 10.0.1 it stopped working for me (Win7 Pro 64 SP1). It hangs Mathematica and needs restart. I tried removing and installing again, same problem. –  rhermans Oct 12 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .