Can I save a manually cropped Image in Mathematica 10 without hard cropping?


In Mathematica 7 I was accustomed to a certain workflow:

  1. Paste an image into a Notebook

  2. Select Actual Size from the context menu, if necessary

  3. Ctrl-drag the control points on the sides of the frame to soft-crop the image

  4. Use File > Save Selection As... to save the cropped image to a file

This workflow is broken in version 10 because in it the entire uncropped image is saved whether I select the image itself or the enclosing Cell frame.

I can use the Crop Tool to crop the image, and that does allow me to save a cropped selection, but it hard-crops the image so that I cannot in the future change my crop selection. (Of the Image in the Notebook.)

If the soft-cropped Image is part of a larger selection (but not merely a Cell containing only the image) the cropped part is indeed saved. This works for saving sections of Notebooks but not images alone.

The only work-around I have found to both keep a soft-cropped Image and save a matching copy is to copy the Image and crop it again with the Crop Tool, then delete the copy. This adds significant time to my workflow.

Is this change a bug or a feature?

Is there another way to accomplish what I want interactively?


Posted 2014-07-16T07:22:45.010

Reputation: 259 163

1I confirm that the described method works in v8.0.4 but in v.10.0.0 the entire uncropped image is saved. OS Win7 x64. – Alexey Popkov – 2014-07-16T08:50:23.960

2I would call it a "usability bug" for sure. One way to avoid making a copy in some scenarios is to use the crop tool, save the image and then press cmd+z (or corresponding undo shortcut on your OS.) – C. E. – 2014-07-16T10:23:37.827

@Pickett Nice idea. I normally operate on the assumption that Mathematica cannot undo, which was usually not far off the mark, but with multiple-undo I should start using it. I suspect there may not be a better answer; consider posting that as one. – Mr.Wizard – 2014-07-16T10:26:53.833

1In 10.4 the cropped image is saved. – Szabolcs – 2016-03-16T11:47:15.457

@Szabolcs Glad to hear it! I think I should tag this as a bug; do you agree? – Mr.Wizard – 2016-03-16T11:48:11.350

1I don't know. I'm confused. I would expect Save Selection As... to save what I see on screen. But I would expect Right Click -> Save Image As... to save the actual image, as it is, and preserve special properties (e.g. a 16-bit images should stay 16-bit and not get cropped by soft-cropping). Both methods save the cropped image in 10.4 – Szabolcs – 2016-03-16T12:22:15.950

BTW in 10.3 it still saves as uncropped. This is a 10.4 change. – Szabolcs – 2016-03-16T12:26:47.457



I think this is a bug rather than a feature. One way to accomplish this that will work in some scenarios without making a copy of the image is to use the crop tool, save the image and then undo the cropping thus restoring the original image.

C. E.

Posted 2014-07-16T07:22:45.010

Reputation: 67 448


It seems that the described method does work in v.10.0.0 if the image is represented as Graphics object. To convert Image to Graphics one can use Show.

The reason why Graphics works is that the soft crop explicitly sets new PlotRange what can be seen by applying Options to the cropped image. But in the case of Image the PlotRange option exists only inside of the box representation in the Notebook and cannot be accessed by Options. Probably this is the direction where a workaround for Image or the source of the problem can be found.


Here is a workaround for Image: after soft cropping the Image paste in the next Input cell and evaluate the following:

(SelectionMove[EvaluationNotebook[], Previous, Cell, 3]; 
Export["test.png", NotebookRead[]])

This exports cropped version of the Image shown in the Notebook. I do not understand however why the number 3 is needed (I have a little experience with SelectionMove). But it works.

Alexey Popkov

Posted 2014-07-16T07:22:45.010

Reputation: 50 220

Great! Now I just need to find a fast way to convert an image into this kind of Graphics. Unfortunately the Graphics Editing > Paste into Graphic command doesn't do it. If you have time to look at that perhaps you can determine why. Thanks. – Mr.Wizard – 2014-07-16T13:29:37.327