3
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ I 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. $\endgroup$ – Alexey Popkov Jul 16 '14 at 8:50
  • 2
    $\begingroup$ I 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.) $\endgroup$ – C. E. Jul 16 '14 at 10:23
  • $\begingroup$ @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. $\endgroup$ – Mr.Wizard Jul 16 '14 at 10:26
  • 1
    $\begingroup$ In 10.4 the cropped image is saved. $\endgroup$ – Szabolcs Mar 16 '16 at 11:47
  • 1
    $\begingroup$ I 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 $\endgroup$ – Szabolcs Mar 16 '16 at 12:22
4
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

UPDATE

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Mr.Wizard Jul 16 '14 at 13:29

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.